Reputation: 23
I have a date in format 2016-05-24T05:07:57.756Z but i want to unset its time attribute.
e.g- 2016-05-25T00:00:00.000Z.
Please help how can I do this.
Upvotes: 0
Views: 171
Reputation: 386560
You could use String#slice
console.log('2016-05-24T05:07:57.756Z'.slice(0, 10) + 'T00:00:00.000Z')
For a date as Date object, you may use Date.UTC()
var utcDate = new Date(Date.UTC(96, 11, 1, 0, 0, 0));
Upvotes: 1
Reputation: 2371
JavaScript's Date object has methods like setHours
, setMinutes
, etc... read about them at https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date
Upvotes: 0