myeatrade

MQL4 Reference

MQL4 Date & Time functions (2)

A group of functions providing the working with data of the datetime type (integer representing the amount of seconds elapsed from midnight, 1 January, 1970).

 

TimeDay()

int TimeDay(datetime date)

Returns day of month (1 – 31) for the specified date.

Parameters:

date   -   Datetime as number of seconds elapsed since midnight (00:00:00), January 1, 1970. 

Sample:

  int day=TimeDay(D'2003.12.31');
  // day is 31

TimeDayOfWeek()

int TimeDayOfWeek(datetime date)

Returns the zero-based day of week (0 means Sunday,1,2,3,4,5,6) for the specified date.

Parameters:

date   -   Datetime as number of seconds elapsed since midnight (00:00:00), January 1, 1970. 

Sample:

  int weekday=TimeDayOfWeek(D'2004.11.2');
  // day is 2 - Tuesday

TimeDayOfYear()

int TimeDayOfYear(datetime date)

Returns day (1 means 1 January,..,365(6) does 31 December) of year for the specified date.

Parameters:

date   -   Datetime as number of seconds elapsed since midnight (00:00:00), January 1, 1970. 

Sample:

  int day=TimeDayOfYear(TimeCurrent());

TimeHour()

int TimeHour(datetime time)

Returns the hour for the specified time.

Parameters:

time   -   Datetime as number of seconds elapsed since midnight (00:00:00), January 1, 1970. 

Sample:

  int h=TimeHour(TimeCurrent());

TimeMinute()

int TimeMinute(datetime time)

Returns the minute for the specified time.

Parameters:

time   -   Datetime as number of seconds elapsed since midnight (00:00:00), January 1, 1970. 

Sample:

  int m=TimeMinute(TimeCurrent());

TimeMonth()

int TimeMonth(datetime time)

Returns the month number for the specified time.

Parameters:

time   -   Datetime as number of seconds elapsed since midnight (00:00:00), January 1, 1970. 

Sample:

  int m=TimeMonth(TimeCurrent());

TimeSeconds()

int TimeSeconds(datetime time)

Returns the amount of seconds elapsed from the beginning of the minute for the specified time.

Parameters:

time   -   Datetime as number of seconds elapsed since midnight (00:00:00), January 1, 1970. 

Sample:

  int s=TimeSeconds(TimeCurrent());

TimeYear()

int TimeYear(datetime time)

Returns year for the specified date. The returned value can be within the range of 1970 to 2037.

Parameters:

time   -   Datetime as number of seconds elapsed since midnight (00:00:00), January 1, 1970. 

Sample:

  int y=TimeYear(TimeCurrent());

TimeLocal()

datetime  TimeLocal()

Returns local computer time as number of seconds elapsed from 00:00 January 1, 1970.

Note: At the testing, local time is modelled and is the same as the modelled last known server time

Sample:

  if(TimeLocal()-OrderOpenTime()<360) return(0);
This article url: http://www.myeatrade.com/442/

Please login to post comment, if you haven't account you can register free