2026-07-18 23:27:05 +03:00
|
|
|
//+------------------------------------------------------------------+
|
|
|
|
|
//| basic.mq5 |
|
|
|
|
|
//| Copyright © 2026, 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( Year(t) );
|
|
|
|
|
Print( Month(t) );
|
|
|
|
|
Print( Day(t) );
|
|
|
|
|
Print( Hour(t) );
|
|
|
|
|
Print( Minute(t) );
|
|
|
|
|
Print( Second(t) );
|
|
|
|
|
Print( DayOfWeek(t) );
|
|
|
|
|
Print( DayOfYear(t) );
|
|
|
|
|
|
|
|
|
|
MqlDateTime dt[1] = {};
|
|
|
|
|
TimeToStructFast(t, dt[0]);
|
|
|
|
|
ArrayPrint(dt);
|
|
|
|
|
|
|
|
|
|
dt[0].year += 1;
|
|
|
|
|
Print(StructToTimeFast(dt[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
|
|
|
|
|
|
|
|
|
|
*/
|