Raju Kumar
Raju Kumar

Reputation: 23

How to unset time attribute of an iso dateTime date format

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

Answers (2)

Nina Scholz
Nina Scholz

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

ahwayakchih
ahwayakchih

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

Related Questions