Convert Datetime

 

Hello,


i want to know the actual time in sekonds since 1970 as its written also here in the output format

https://www.mql5.com/en/docs/convert/stringtotime


i try to use 

Print( StringToTime(TimeCurrent()));

but as output in the terminal i always get the format


YYYY.MM.DD hh.mm.ss


does i do something wrong or is there an mistake in the documentation?


amando

Documentation on MQL5: Conversion Functions / StringToTime
Documentation on MQL5: Conversion Functions / StringToTime
  • www.mql5.com
Conversion Functions / StringToTime - Reference on algorithmic/automated trading language for MetaTrader 5
 

TImeCurrent() returns a datetime, so you don't have to use a StringToTime() function, it's already a (date)time.

If you want to format your output you have to use TimeToString(). See documentation.

 
Print(TimeToString( TimeCurrent()), "    ", StringToTime(TimeCurrent()) );

my code for testing


the result


i dont see that much difference

 
Comment((long)TimeCurrent());
 

Thanks Kypa

i dont understand why i have to put long in front but it works


amando

 
kypa:

I see now I misread the question.

 

Because 1970 was a long, long time ago. :D

datetime and long are both big integers, terminal translates datetime in human-friendly form. This way you command it show it as the big integer it is, without the translation.

Reason: