-
Notifications
You must be signed in to change notification settings - Fork 0
DateFormatter convertToDate
MarkusWME edited this page May 20, 2016
·
5 revisions
DateFormatter - convertToDate
Date convertToDate([number timestamp])
Returns a Date object representing the given timestamp or a Date object representing the current time if no timestamp is given.
timestamp The optional timestamp from which the Date object should be created.
Returns the Date object representing the given timestamp. If no timestamp has been given a Date object of the current time will be created. If the timestamp already is a Date object the original object will be returned.
This function doesn't throw any exception.
var dateFormatter = new DateFormatter();
// Get the current date and time
console.log(dateFormatter.convertToDate().getTime());
// Get the date object with the timestamp of the 1st April 2016 at 00:00:00
console.log(dateFormatter.convertToDate(1459468800000).getTime());
// Get a date object with a Date object as timestamp parameter
console.log(dateFormatter.convertToDate(new Date(2016, 6, 9, 12, 34, 56).getTime());
This will lead to an output like this:
1464116400000
1459468800000
1468067696000