Problems with UTC DateTime

I currently store all dates in DB as UTC dates. Each offset of the user's time zone is also stored in the database. When I get the date, it is converted back to its local date using this offset.

The problem occurs when I get the date using an ajax call. I think the date (which is already converted using the offset) is returned as a Java Date object. The browser then decides to associate my date with the addition of the time zone offset of the client computers to the Date object. This leads to the fact that the dates will be one day ahead of what they should be if the time component exceeds 11.59 in the morning.

The only solution I can come up with is to pass them as strings, and in this case, of course, this will not happen. For me, this is laaaast resort, and I would like to find the best solution or workaround for this problem.

+4
source share
1 answer

Your browser does not bother with dates indicated in that browsers do not have a date wrap variable. You have something else that does. How do you post your dates in ajax? Json Json will only send numbers or strings. XML will only send strings.

Something will convert your sent date to a javascript date object, find out what it is.

+2
source

All Articles