Javascript is not Java.
Fortunately, there are libraries like datejs
.
Datejs is an open-source JavaScript Date Library.
Comprehensive, yet simple, stealthy and fast. Datejs has passed all trials and is ready to strike. Datejs doesn’t just parse strings, it slices them cleanly in two.
For an example, see the set()
method:
set
.set ( Object config ) : Date
Set the value of year, month, day, hour, minute, second, millisecond of date instance using given configuration object.
// returns Jul 15 2008 18:45:30
Date.today().set({millisecond: 500, second: 30, minute: 45, hour: 18, day: 15, month: 6, year: 2008});