0 Views
0 Downloads
0 Favorites
basic
ÿþ//+------------------------------------------------------------------+

//|                                                        basic.mq5 |

//|                                        Copyright © 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



*/

Comments