Skip to content
spencer kelly edited this page Sep 16, 2021 · 4 revisions

You can create a specific date + time by using a variety of inputs, whichever is most useful to you.

Spacetime supports all the JavaScript-date input formats:

ISO Date  "2015-03-25"
Short Date  "03/25/2015" or "2015/03/25"
Long Date "Mar 25 2015" or "25 Mar 2015"
Full Date "Wednesday March 25 2015"
Epoch Time      1493042538

As well as some more structured formats, like:

// array-inputs
spacetime([2019, 0, 1,6,30]) // January 1st, 2019, 6:30am

// object input
spacetime({year:2016, month:1, date:3})// February 1st, 2016

As in the JavaScript Date object, when there is information missing, ASpace fills in the missing details with your current, local time:

// Will be June, with your current year, date, and time
spacetime({month:'june'}) 
// June 3rd, 2017, 12:02pm (or whatever)

Please note: to stay consistent with the JavaScript spec, JavaScript inputs use 1-based months, like regular people use.

Array, and Object-based inputs use 0-based months, due to the assumption that they are used dynamically in software.

Like always, dates of the month are 1-based, in every condition.

Lastly, spacetime objects can be used as input, which is a nice-helper sometimes:

let a = spacetime.now()
let b = spacetime(a)
a.isSame(b, 'minute') 
//true
Clone this wiki locally