Reputation: 15984
I have an object containing a javacsript date. Something like this:
var obj = {
startTime: new Date()
....
}
When Angularjs converts the object to JSON (for example, when sending it over $http), it converts the date to a string such as:
2015-12-20T15:35:15.853Z
I would like to have a timestamp instead of this string. What is the best way to achieve this?
Upvotes: 0
Views: 66
Reputation: 8971
Use the getTime()
method to get a unix timestamp from a Date
object:
var obj = {
startTime: (new Date()).getTime()
}
Upvotes: 3