• 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.
  • Posts

  • Recent Achievements

    • Week One Done
      Huge Trailer earned a badge
      Week One Done
    • Week One Done
      Classifyskilleducation earned a badge
      Week One Done
    • One Month Later
      eurospharma62 earned a badge
      One Month Later
    • Week One Done
      With What earned a badge
      Week One Done
    • Week One Done
      Harris Gilbert earned a badge
      Week One Done
  • Popular Contributors

    1. 1
      +primortal
      549
    2. 2
      +Edouard
      169
    3. 3
      PsYcHoKiLLa
      72
    4. 4
      Michael Scrip
      64
    5. 5
      ATLien_0
      64
  • Tell a friend

    Love Neowin? Tell a friend!