Note that there are some explanatory texts on larger screens.

plurals
  1. POGet correct date value from .NET DateTime JSON format string in Javascript
    primarykey
    data
    text
    <p>I have a javascript application which receives data from ASP.NET WebService in JSON format. My application has a lot of manipulations with dates which it also receives from WebService. </p> <p>WebService stores all dates in EST timezone and sends them in such format: </p> <pre><code>{"Date":"\/Date(1319205600000+0300)\/"} </code></pre> <p>to my javascript application.</p> <p>On the client side I should display all dates also in EST timezone irrespectively of browser's timezone. So if I receive from the server the representation of:</p> <blockquote> <p>10/21/2011 10:00 </p> </blockquote> <p>I should display exactly the same time to the user.</p> <p>So to convert dates I do something like this:</p> <pre><code>function convert_date(millisec) { var date = new Date(millisec), local_offset = date.getTimezoneOffset(), server_offset = -5 * 60, //EST offset diff = (local_offset + server_offset) * 60000; return new Date(millisec + diff); } </code></pre> <p>But the point is that <code>server_offset</code> not always should be -5. It can be -4 depending on DST value. I've tried to do <code>server_offset = (date.isDST() ? -4 : -5) * 60</code> instead but I haven't found any solution for capturing <code>isDST()</code> which works fine for all the local client timezones. Most of them work fine for that local browser's timezone which has the same value of DST as EST timezone but would fail in the case of GMT+5:30 timezone for example.</p> <p>So are there any way to determine whether DST would be applied for some specific date in EST timezone from javascript?</p> <p>Or maybe I've missed something?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload