MultiScript - Date/Time Functions

×

Warning message

  • Filefield sources: remote plugin will be disabled without php-curl extension.
  • Filefield sources: remote plugin will be disabled without php-curl extension.
GetTime Get the current date and time
FormatDate Format a date
FormatTime Format a time
TimeLocal2UTC Convert a time value from local to UTC
TimeUTC2Local Convert a UTC time value to local time
ParseDateTime Convert a Date/Time string to a time value

Related

GetFileTime / SetFileTime

GetTime

Get the current date and time.

<num> GetTime([<num> getUTCTime]);

Parameters

getUTCTime
(Optional, default: 0)
If 1, the time will be UTC else it will be local time. If not set, local time is used

Return Value

The number of seconds since 1-Jan-1970 00:00:00

Example

@var $nowLocal = GetTime();
@var $nowUTC = GetTime(1);

FormatDate

Format a number to its date value.

<str> FormatDate(<str> format, <num> datevalue);

Parameters

format
Date formatting string
datevalue
The number of seconds since 1-Jan-1970 00:00:00

Notes

See Date Formatting to see how to format dates

Return Value

A formatted date string

Example

@var $now = GetTime();
@var $date = FormatDate( "yyyy-MM-dd" , $now );

FormatTime

Format a number to its time value.

<str> FormatTime(<str> format, <num> timevalue);

Parameters

format
Time formatting string
timevalue
The number of seconds since 1-Jan-1970 00:00:00

Notes

See Time Formatting to see how to format times

Return Value

A formatted time string

Example

@var $now = GetTime();
@var $date = FormatTime( "HH:MM:SS" , $now );

TimeLocal2UTC

Convert a time value from local to UTC.

<num> FormatTime(<num> timevalue);

Parameters

timevalue
The number of seconds since 1-Jan-1970 00:00:00

Return Value

A time value converted to UTC

Example

@var $now = GetTime();
@var $utc = TimeLocal2UTC($now);
@var $date = FormatTime( "HH:MM:SS" , $utc );

TimeUTC2Local

Convert a UTC time value to local time

<num> TimeUTC2Local(<num> timevalue);

Parameters

timevalue
The number of seconds since 1-Jan-1970 00:00:00

Return Value

A time value converted from UTC to local

Example

@var $now = GetTime();
@var $utc = TimeLocal2UTC($now);
@var $local = TimeUTC2Local($utc);
// $local and $now should now be the same
@var $date = FormatTime( "HH:MM:SS" , $local );

ParseDateTime

Convert a Date/Time string to a time value

<num> ParseDateTime(<str> strDateTime, <str> format);

Parameters

strDateTime
A Date/Time as a string
format
A Date/Time formatting string

Return Value

A Date/Time string converted to a numeric value
Formatting information is available here: http://pubs.opengroup.org/onlinepubs/009695399/functions/strptime.html

Example

@var $str = "2012-01-01 12:32:11";
@var $val = ParseDateTime($str, "%Y-%m-%d %H:%M:%S");