0

I want to work in same timezone in my web application, I try to use de time zone default function moment.tz.setDefault("Europe/Madrid"); the dates conversions (json format) are bad, substact one day by default

Here is my plunker

http://plnkr.co/edit/xsugHtDLLUfxugCJRwIZ?p=preview

Thanks

 var jsonDate = "/Date(118101600000)/"; // DD/MM/YY = 29/09/1973 

 alert(moment(jsonDate).format("DD/MM/YY")); // conversion ok

 moment.tz.setDefault("Europe/Madrid");

 alert(moment(jsonDate).tz('Europe/Madrid').format("DD/MM/YY")); // substract one day by default 28/09/1973
 alert(moment(jsonDate).format("DD/MM/YY"));                     // substract one day by default 28/09/1973
Kaken
  • 163
  • 5
  • 9
  • I've changed the way that work with dates to avoid client conversions. Now I return the date in ISO format from the server. – Kaken Apr 29 '15 at 10:48

1 Answers1

1

@kaken

Can u check this link

I followed that link to solve timezone issue.

ex: moment(jsonDate).zone("+03:00"); // moment can able to parse JsonDate

To work with named timezones, include Moment Timezone as well and use .tz()

// determines the correct offset for America/Phoenix at the given moment

moment(1369266934311).tz('America/Phoenix').format('YYYY-MM-DD HH:mm')

// always "2013-05-22 16:55"
Community
  • 1
  • 1
Sajjad Ali Khan
  • 1,735
  • 2
  • 20
  • 17