Alright, so my website allows people to store their work schedules. They enter their shift starting datetime and ending datetime. Simple enough, right?
The idea is I can look at the site and see Bob's working in Chicago tonight from 4-6pm, and Joe's working in New York from 8-10pm. And that's how I want the dates displayed in the app. If I'm viewing the site from California, I still want to display Chicago
times for Bob, and New York times for Joe. I do NOT want to convert those times to California times where it'd show Bob working from 2-4pm, and Joe working from 5-7pm.
My site has sample data and when everything's located in the same timezone it's fine, but I've now deployed it to Azure servers in North Central US (It uses SQL Azure located there as well, although I'm unclear on where there is), and now the date and times
are all off (jumped forward by 7 hours).
I believe the reason for this is that I use a lot of Ajax and JSON, and JSON requires datetimes to be formatted like this
/Date(1240718400000)/, where the number represents the milliseconds since epoch/Unix time. I display the schedules in a Calendar/Week/or Day view, which requires a lot of javascript datetime comparisons.
Anyway, anyone know the correct way to do what I need to do? I'm thinking I need to store the datetimes as UTC, but I also need to know the timezone where the user's work shift will take place, and then I need to adjust it on the C# side, but then do I
need to do anything on the javascript side?
I'm just confused, seems like too many variables to wrap my head around at the moment.
redwing19
Member
400 Points
180 Posts
DateTime issues with Azure c#, javascript, sql....so confused.
May 28, 2012 06:43 PM|LINK
Alright, so my website allows people to store their work schedules. They enter their shift starting datetime and ending datetime. Simple enough, right?
The idea is I can look at the site and see Bob's working in Chicago tonight from 4-6pm, and Joe's working in New York from 8-10pm. And that's how I want the dates displayed in the app. If I'm viewing the site from California, I still want to display Chicago times for Bob, and New York times for Joe. I do NOT want to convert those times to California times where it'd show Bob working from 2-4pm, and Joe working from 5-7pm.
My site has sample data and when everything's located in the same timezone it's fine, but I've now deployed it to Azure servers in North Central US (It uses SQL Azure located there as well, although I'm unclear on where there is), and now the date and times are all off (jumped forward by 7 hours).
I believe the reason for this is that I use a lot of Ajax and JSON, and JSON requires datetimes to be formatted like this /Date(1240718400000)/, where the number represents the milliseconds since epoch/Unix time. I display the schedules in a Calendar/Week/or Day view, which requires a lot of javascript datetime comparisons.
Anyway, anyone know the correct way to do what I need to do? I'm thinking I need to store the datetimes as UTC, but I also need to know the timezone where the user's work shift will take place, and then I need to adjust it on the C# side, but then do I need to do anything on the javascript side?
I'm just confused, seems like too many variables to wrap my head around at the moment.