1

I am using the below function to convert Date to timestamp but it is taking timezone I need only the date with no timezone to Instant type

convertDateToTimeStamp(date: any) {
  return Date.parse(date) / 1000;
}

Before calling convertDateToTimeStamp() the date value is **Fri Mar 24 2017 00:00:00 GMT-0400 (Eastern Daylight Time)****

After calling the convertDateToTimeStamp() the date value is 1490328000 which is Thursday, November 26, 2015 12:00:00 AM GMT-05:00

I dont need any GMT , the date should be same across all the timezones

1
  • Are you using TypeScript? The question seems independent of Angular. Please edit tags if this is the case. Commented Jan 31, 2019 at 7:18

1 Answer 1

1
convertDateToTimeStamp(date: any) {
  return new Date(date).toUTCString();
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.