• 0

[C#] DateTime changes when passed to a web service


Question

When I pass a date time object (via serialization) to the server web service, it converts it to have an offset that matches the servers time. Is there a way to force it to just keep the local time

as it's being converted. I don't care about the time zones, I just care about the clients local time and their time only. The client uploads a file and the database stores their local machine time with it,

not the servers. The servers machine time will NEVER matter in this solution. So if it's 7 PM EST I don't want it being sent then converted to 4 PM PST when the web service reads it.

5 answers to this question

Recommended Posts

  • 0

UtcNow just returns the current utc time though. That won't help me convert the existing db rows of datetime to utc, so how would that work?

Ex:

FileSvcDef fileDef = request.FileSvcDefLst[i]; // <------------------- this has a datetime property that I passed via a web service and once it hits the server changes the timezone 3 hours back.
lastSyncDate = (DateTime)mReader["file_last_sync"]; // This is the right time coming straight from the database.
FileSvcSyncDef fileSyncDef = new FileSvcSyncDef(fileDef.GameId, -1, fileDef.FileName, (DateTime)lastSyncDate, fileDef.DirPath, SyncLocation.Server);

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.