about time

 

hi all, i want invert  date and time to secounds since from 1/1/1970, but it gives me error , for example i wrote Print("sall" StrToTime(2021.02.05 05:05)); on void onTick, but it gives me error like .05 some operator expected,  and 05 unexpected token?

whats the problem?

 
ejmin ejoni:

hi all, i want invert  date and time to secounds since from 1/1/1970, but it gives me error , for example i wrote Print("sall" StrToTime(2021.02.05 05:05)); on void onTick, but it gives me error like .05 some operator expected,  and 05 unexpected token?

whats the problem?

What do you mean by "invert"?

StrToTime uses a string parameter, you are using a datetime format.

Use TimeToString().

 
Keith Watford:

What do you mean by "invert"?

StrToTime uses a string parameter, you are using a datetime format.

Use TimeToString().

is there any way to convert datetime to secounds from 1/1/1970 directly?

 
ejmin ejoni:

is there any way to convert datetime to secounds from 1/1/1970 directly?

try

   datetime time=D'2021.02.05';
   int seconds=(int)time;
 
Keith Watford:

try

thanks it works
 
ejmin ejoni: whats the problem?
Print("sall"  StrToTime( 2021.02.05 05:05 ));
             ^__________ ___________^__________ no operation (plus sign to append)
                              ^_____ __________ a.b.c is not a valid number.
                                      ^________ a:b is not a valid number.
                        ^________________^_____ StrToTime requires a string. (quotes)
Reason: