rivkamak
asked on
EJS converting my dat to my timezone
I am trying to set up an express website.
I am getting data from a database in date formats, ie : 2018-11-21T00:00:00.000Z,
My database just default the time to 0000Z, but the day should be 11/21/2018
Whenever I try to display the date,
even as a simple ejs write: <%=item.date %>
it's automatically converting it to my timezone MST, and I'm getting the date as
Tue Nov 20 2018 17:00:00 GMT-0700 (Mountain Standard Time)
How can I set up a standard across my app to keep it as the same day of the month ?
I am getting data from a database in date formats, ie : 2018-11-21T00:00:00.000Z,
My database just default the time to 0000Z, but the day should be 11/21/2018
Whenever I try to display the date,
even as a simple ejs write: <%=item.date %>
it's automatically converting it to my timezone MST, and I'm getting the date as
Tue Nov 20 2018 17:00:00 GMT-0700 (Mountain Standard Time)
How can I set up a standard across my app to keep it as the same day of the month ?
ASKER
I am more concerned that the date that is coming through the database. it should drop the hours and timezone.
and keep the date in the same day of the month.
Will that help?
and keep the date in the same day of the month.
Will that help?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toDateString
or else you can use http://momentjs.com/docs/momentjs along with format function to get something like this..
<%= moment(user.date).format( 'MM/DD/YYYY') %>