Spiderscript - Reference - SS.datetime

SS.datetime provides extermely useful date and time parsing and formatting functions.

Format Specifier Function Example
yyyy Four digit year dd/MM/yyyy - 17/04/2008
yy Two digit year dd/MM/yy - 17/04/08
MMMM Month Full Name dd MMMM yyyy - 17 April 2008
MMM Month Short Name dd MMM yyyy - 17 Apr 2008
MM Month Number Double Digit dd MM yyyy - 17 04 2008
MM Month Number Single Digit dd M yyyy - 17 4 2008
dddd Day Full Name dddd dd MMMM yyyy - Thursday 17 April 2008
ddd Day Short Name ddd dd MMMM yyyy - Thu 17 April 2008
dd Day Two Digits/td> dd MMMM yyyy - 09 April 2008
d Day Single Digit d MMMM yyyy - 9 April 2008
hh Two Digit 12 Hour Clock (does not exceed 12) hh:mm:ss - 07:05:23
h Single Digit 12 Hour Clock (does not exceed 12) h:mm:ss - 7:05:23
HH Two Digit 24 Hour Clock HH:mm:ss - 07:05:23
H Single Digit 24 Hour Clock H:mm:ss - 7:05:23
mm Minutes Two Digits HH:mm:ss - 19:05:23
ss Seconds Two Digits HH:mm:ss - 19:05:23
fff Fraction of a second - Three Digits HH:mm:ss.fff - 19:05:23.123
ff Fraction of a second - Two Digits HH:mm:ss.ff - 19:05:23.12
f Fraction of a second - Single Digit HH:mm:ss.f - 19:05:23.1

Global Functions:

Functions:

Members:

Global Functions
$datediff()
Returns the difference between two dates. Given two JavaScript date objects, the difference is calculated between the two and returned in the specified format. If no format has been specified then the difference is returned in milliseconds.
Format Values:-
  • ms - Milliseonds
  • s - Seconds
  • mi - Minutes
  • h - Hours
  • d - Days
{Date} date1
{Date} date2
{String} format - See format values above.
{Integer} - Difference in range set by format value
v1.0.0.20080527
[Top]
Functions
SS.datetime.difference
Returns the difference between two dates. Given two JavaScript date objects, the difference is calculated between the two and returned in the specified format. If no format has been specified then the difference is returned in milliseconds.
Format Values:-
  • ms - Milliseonds
  • s - Seconds
  • mi - Minutes
  • h - Hours
  • d - Days
{Date} date1
{Date} date2
{String} format - See format values above.
{Integer} - Difference in range set by format value
v1.0.0.20080527
[Top]
SS.datetime.format
Format Date Formats the Date object given into the specified format
d - {Date} - Date
f - {String} - Format
l - {SS.locale} - Locale settings (optional)
s - {String}
Null (if date and / or format not specified)
v1.0.0.20080527
[Top]
SS.datetime.fromString
Get Date From String Takes a string input and returns its date/time representation as a date object
s - {String} (string representation of the date e.g. ("01/02/2000")
f - {String} - (optional) Override Default Format (defaultFormat(df) the date/time should be in. "MM/dd/yyyy" = Default date format.)
d - {Date)
Null (string input is not recognised as a valid date / time)
v1.0.0.20080527
[Top]
SS.datetime.getFormat
Get Date / Time Format From String Get the date / time format of the date from the string representation of the date / time
s - {String} - String representation of the date / time
f - {String} - (optional) Override Default Format (defaultFormat(df) the date/time should be in. "MM/dd/yyyy" = Default date format. If not specified, then all matches are returned.)
s - {String} - matched format
null - format not found
a - {Array} - Array of {String} formats if more than one date was found.
v1.0.0.20080527
[Top]
Members
SS.datetime.formats : Array
Date Formatting Regular Expressions Array containing the regular expressions used in parsing date / time strings
v1.0.0.20080527
[Top]