TimeUtils/basic.mq5

48 lines
2.4 KiB
MQL5
Raw Permalink Normal View History

2025-09-19 20:26:04 +00:00
<EFBFBD><EFBFBD>//+------------------------------------------------------------------+
//| basic.mq5 |
//| Copyright <EFBFBD> 2024, Amr Ali |
//| https://www.mql5.com/en/users/amrali |
//+------------------------------------------------------------------+
#include "TimeUtils.mqh"
void OnStart()
{
datetime t = TimeLocal();
Print( t2s(t, TIME_DATE|TIME_SECONDS) ); // Formats time with the weekday name
Print( GetYear(t) );
Print( GetMonth(t) );
Print( GetDay(t) );
Print( GetHour(t) );
Print( GetMinute(t) );
Print( GetSecond(t) );
Print( DayOfWeek(t) );
Print( DayOfYear(t) );
MqlDateTime st[1] = {};
TimeToStruct(t, st[0]);
ArrayPrint(st);
st[0].year += 1;
Print(StructToTime(st[0]));
}
//+------------------------------------------------------------------+
/*
example output:
Tue, 2024.12.03 20:46:58
2024
12
3
20
46
58
2
337
[year] [mon] [day] [hour] [min] [sec] [day_of_week] [day_of_year]
[0] 2024 12 3 20 46 58 2 337
2025.12.03 20:46:58
*/