Pages

Subscribe:

Friday, May 27, 2011

Date and time functions

Date and time functions
CurTime ()
Day ()
DayOfWeek ()
DayOfYear ()
Hour ()
LocalTime ()
Minute ()
Month ()
Seconds ()
TimeDay ()
TimeDayOfWeek ()
TimeDayOfYear ()
TimeHour ()
TimeMinute ()
TimeMonth ()
TimeSeconds ()
TimeYear ()
Year ()


datetime CurTime ()

Returns last known time server, number of seconds elapsed from 00:00 January 1, 1970.
Sample
if (CurTime () - OrderOpenTime () <360) return (0);


Day int ()

Returns the current date is the day of the month.
Sample
if (Day () <5) return (0);


int DayOfWeek ()

Returns the current date is zero-based day of week (0-Sunday, 1,2,3,4,5,6).
Sample
/ / No work on holidays.
if (DayOfWeek () == 0 | | DayOfWeek () == 6) return (0);


int DayOfYear ()

Returns the current date is the day of the year (January 1-1, .., 365 (6) - 31 December).
Sample
if (DayOfYear () == 245)
return (true);


Hour int ()

Returns the current hour (0,1,2, .. 23)
Sample
bool is_siesta = false;
if (time ()> = 12 | | Hour () <17)
is_siesta = true;


datetime LocalTime ()

Returns local computer time, number of seconds elapsed from 00:00 January 1, 1970.
Sample
if (ServerTime () - OrderOpenTime () <360) return (0);


minute int ()

Returns the current minute (0,1,2, .. 59).
Sample
if (minute () <= 15)
return ("first quarter");


Month int ()

The current month is returned as a number (1 January 2,3,4,5,6,7,8,9,10,11,12).
Sample
if (month () <= 5)
return ("the first half of the year");


int seconds ()

Returns the current second (0,1,2, .. 59).
Sample
if (Seconds () <= 15)
return (0);


int TimeDay (datetime date)

Returns day of month (1-31) for a particular date.
Parameters

Date - DateTime is the number of seconds elapsed since midnight (12:00:00), January 1 1970th
Sample
int day = TimeDay (D'2003 .12.31 ');
/ / Day is 31


int TimeDayOfWeek (datetime date)

Returns zero-based day of week (0-Sunday, 1,2,3,4,5,6) for a particular date.
Parameters

Date - DateTime is the number of seconds elapsed since midnight (12:00:00), January 1 1970th
Sample
int weekday = TimeDayOfWeek (D'2004 .11.2 ');
/ / Day is 1 - Tuesday


int TimeDayOfYear (invalid date)

Returns day (January 1-1, .., 365 (6) - December 31) of the year for a certain date.
Parameters

Date - DateTime is the number of seconds elapsed since midnight (12:00:00), January 1 1970th
Sample
int day = TimeDayOfYear (CurTime ());


int TimeHour (datetime time)

She returned an hour for a specified time.
Parameters

time - DateTime is the number of seconds elapsed since midnight (12:00:00), January 1 1970th
Sample
int h = TimeHour (CurTime ());


int TimeMinute (datetime time)

Minute returns for a certain time.
Parameters

time - DateTime is the number of seconds elapsed since midnight (12:00:00), January 1 1970th
Sample
int m = TimeMinute (CurTime ());


int TimeMonth (datetime time)

Returns month for a specified time.
Parameters

time - DateTime is the number of seconds elapsed since midnight (12:00:00), January 1 1970th
Sample
int m = TimeMonth (CurTime ());


int TimeSeconds (datetime time)

Returns for a second time.
Parameters

time - DateTime is the number of seconds elapsed since midnight (12:00:00), January 1 1970th
Sample
int m = TimeSeconds (CurTime ());


int TimeYear (datetime time)

Returns on a certain date. Return values ​​can be in the range 1970-2037.
Parameters

time - DateTime is the number of seconds elapsed since midnight (12:00:00), January 1 1970th
Sample
int y = TimeYear (CurTime ());


Year int ()

Returns the current year.
Sample
/ / Return if the date before May 1, 2002
if (year () == 2002 & & Month () <5)
return (0);

0 comments:

Post a Comment