date

Contains utility functions for dealing with dates.

Methods:

create_date
date_to_UTC_string
date_to_UTC_timestamp
date_to_string

Direct Link

create_date

( date_string, time_string, [options] )
Creates a Date object given a date and time.

Parameters

  • date_string String
    e.g. 2011-10-31
  • time_string String
    e.g. 12:00am or 1:00pm
  • [options] Object Optional
    Additional options:
    • [utc] Boolean Optional
      If true, the passed in datetime is UTC time.
      Defaults To: false

Returns

Date
The passed-in date, represented as a JavaScript Date object.

Direct Link

date_to_UTC_string

( date )
Takes a Date object and returns a UTC date and time string.

Parameters

  • date Date
    The JavaScript Date object.

Returns

String
The passed-in date, represented as a UTC date and time string ex. "2011-10-31 12:00:00" (12pm on Halloween).

Direct Link

date_to_UTC_timestamp

( date )
Takes a Date object and returns a UTC timestamp which represents the number of seconds since January 1, 1970.

Parameters

  • date Date
    The Javascript Date object.

Returns

Number
The passed-in date, represented as a UTC timestamp.

Direct Link

date_to_string

( date, [options] )
Takes a Date object and returns an object containing various date and time formats in local time.

Parameters

  • date Date
    The JavaScript Date object.
  • [options] Object Optional
    Additional options:
    • [military] Boolean Optional
      If true, returns the date in military (24h) format, if false, returns it in standard (12h) format.
      Defaults To: true

Returns

Object
The passed-in date, represented in various formats in an object as follows:
- date (ex. 2011-01-01)
- time (ex. 01:00pm)
- time_no_pad (ex. 1:00pm)