swifty
swifty

Reputation: 59

how to remove timezone ionic and compare the date

I have a problem with removing the timezone in typescript, I was trying to get the actual date on the day and then convert it to string, but it gives a timezone on the last character. I want to compare the date from firebase and the date from the actual day in ionic to show the data from firebase. Here is the code

myDate = new Date().toISOString().toString();

and its the result on the firebase 2017-12-16T15:25:51.984Z

the format date that i want is 2017-12-16

is it possible to compare the string on typescript

Upvotes: 0

Views: 1359

Answers (1)

Anshul
Anshul

Reputation: 395

YOu are getting the date format

myDate = new Date().toISOString().toString();

and result is 2017-12-16T15:25:51.984Z

now we can use,

let dateFormat = myDate.split('T');

so you will get the two values in array i.e

dateFormat = ["2017-12-16", "15:25:51.984Z"]

and you can use dateFormat[0] for getting date.

Upvotes: 1

Related Questions