res.json({data: new Date()});
This is the response: {data: '2014-05-20T01:40:34.993Z'}
How to configure express to return timestamp instead of date string?
{data: 1343235454545}
You need to use Date.now()
Example - res.json({data: Date.now()});
Then you will get result in timestamp "data": 1404359477253
likewise.
This worked out perfectly to filter all Date
app.set('json replacer', function (key, value) {
if (this[key] instanceof Date) {
// Your own custom date serialization
value = this[key].now();
}
return value;
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With