Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6008327
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T01:48:30+00:00 2026-05-23T01:48:30+00:00

One of the nastiest problems working across time zones :) Here is my problem:

  • 0

One of the nastiest problems working across time zones 🙂

Here is my problem:

  1. I have code that passes date into WCF via JSON object and I use “short” format where it contains only milliseconds since 1970 with no time zone. This DateTime parsed by WCF just FINE

  2. I store date into SQL Server Database. Example: 2011-06-07 22:17:01.113 – date as I see it in SQL Server and this is perfectly fine since I store everything in UTC. So, it’s (-5) time zone and date looks right.

  3. I load date field into my object using EF and inside object property says it is 22:17 and Kind=Unspecified which is OK again, it is loaded from SQL, I know it is UTC but code doesn’t know that so it loads this date as Unspecified.

  4. I return this object to WCF client. It can be XML or it can be JSON. Here is what happen. When I JSON(this is what client specifies) – I get this: 1307503021113-0500 for date. If we convert first portion to DateTime using SQL:

SELECT DATEADD(ss, 1307503021,
‘1970-01-01’)

2011-06-08 03:17:01.000

Part above already wrong, no? If we apply -5hr adjustment we will be back to 22:17pm which already utc time? This part already confusing to me. But what even worse – when I deserialize using JavaScriptSerializer – I see DateTime value in newly inflated object saying UTC kind and 3:17am

var oSerializer = new JavaScriptSerializer();
                var returnValue = (T)oSerializer.Deserialize(s, typeof(T));

I’m all puzzled already and I wonder if it’s possible to force WCF and other serializer/deserializers to NOT do any time offsets and stuff? I’d rather format all dates for display manually and I want to store UTC dates in database.

UPDATE:

Looks like WCF thinks that if DateKind is Unspecified than it’s LOCAL.
I did this: After I got objects from EF I specified Kind:

foreach (var tu in tripUpdates)
                {
                    tu.DeviceTime = DateTime.SpecifyKind(tu.DeviceTime, DateTimeKind.Utc);
                }

That fixed it – now when WCF serves object it doesn’t include timezone which is GREAT. Now my main question is there any way to specify Kind on EF entities somehow so I don’t have to manually specifiy kind for every date in service?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T01:48:31+00:00Added an answer on May 23, 2026 at 1:48 am

    When you get the datetime via a SELECT statement always set the DateTime.Kind to UTC. This way WCF/XML will not try to adjust the time.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

One little problem: I have this class for working with CouchDB in PHP. I
One thing that I like to do from time to time is do a
one more time i'm in trouble here. My point is: In my project i
One of my action outputs a csv file. The problem is if a field
One of the neat characteristics of UTF-8 is that if you compare two strings
One can say a type parameter T must have a specific supertype S_1: class
One car must have one owner, and an owner can have many cars.
One has txtDateReceived and second has txtVendorPackDate. Before insert will add record I have
One of my sites has a lot of users. They currently each have one
I have a piece of mature geospatial software that has recently had areas rewritten

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.