Date and time library

<< Click to Display Table of Contents >>

Navigation:  Project > Scripts > ST language > Embedded functions >

Date and time library

Previous pageReturn to chapter overviewNext page

datetime(Input) -  used to get date and time components depending on Input value:

0 - get seconds.

1 - get minutes.

2 - get hour of the day considering AM/PM.

3 - get hour of the day.

4 - get day of the week (1-Sunday, 2-Monday…).

5 - get day of month.

6 - get month (0 - January, 1 - February…).

7 - get year.

8 - get minutes of the day (hour*60 + minutes).

 

Example:

int a = datetime(7);

print(a);

Response:

a = 2020;


 

currentdatetime(Input1) - used to get current date and time in string format. Input1 contains format of the date and time. Function returns formatted current date and time.

 

Example:

string date = currentdatetime(“YYYY-MM-dd HH:mm:ss”);

Response:

date = "2020-09-15 14:22:12"


 

datetimefrom(Input1, Input2) - used to convert date time in milliseconds since 1 January 1970 into string format. Input1 contains format of the date and time. Input2 contains date time in milliseconds since 1 January 1970. Function returns formatted date and time in string.

 

Example:

string date = datetimefrom(“YYYY-MM-dd HH:mm:ss”, 1603713302140);

Response:

date = "2020-10-26 11:22:52"

 


 

datetimeto(Input1, Input2) - used to convert date time in string format into milliseconds since 1 January 1970. Input1 contains format of the date and time. Input2 contains date time in string format. Function returns time in milliseconds since 1 January 1970.

 

Example:

long date = datetimeto(“YYYY-MM-dd HH:mm:ss”, "2020-10-26 11:22:52");

Response:

date = 1603713302140