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

  • SEARCH
  • Home
  • 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 591553
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T15:38:47+00:00 2026-05-13T15:38:47+00:00

I’ve got a WCF service which receives records with datetime values, and saves them

  • 0

I’ve got a WCF service which receives records with datetime values, and saves them to an Azure SQL db, using Entity Framework 3.5, SP1. Running it locally, the records get saved to the database, all is well

However, my IIS hosting is in a different timezone. When I upload the site to there and call the same service (with the exact same connection string, to the Azure SQL db), the records still get saved, but the time has moved back 5 hours.

I’ve checked Fiddler, to watch the data going out, and it’s in my local time. I’ve used the same service inside Azure hosting, and that saved fine too. I’ve got the same data going to another WCF service on the same host being saved with Linq2SQL, and that saves fine.

The only difference then is Entity Framework – I’m guessing that my timezone information (GMT) is sent with the datetime, and so when the server in Eastern Seaboard time receives it, it converts it to the local time, 5 hours earlier.

In a way, this is accurate, because at the moment (13:48), it is 5 hours earler – 08:48, but that’s not what I want it to save to the database, I want it to save 13:48. Like I asked it to, so it makes sense when I query it

This is probably really simple, and everyone else knows the answer, but I am a little puzzled. I’d really appreciate it if someone could point me in the right direction.

many thanks

Toby

  • 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-13T15:38:48+00:00Added an answer on May 13, 2026 at 3:38 pm

    You could try changing the DateTimeKind on the client side value to Unspecified. That way WCF and the Entity Framework won’t have enough information to try and be clever about converting it.

    DateTime.SpecifyKind
    DateTimeKind


    Following up on this not working and your comment in the question…

    Firstly, what are you trying to do – do you want the values stored in the database to be in the client’s timezone – in your case UK time – or do you want it to be stored in UTC? In my experience the best solution is to save it as UTC otherwise you will really confuse things if you have multiple clients in different timezones.

    Assuming you do want to store it as UTC then you need to convert it to UTC on the client side before passing it over the network (DateTime.ToUniversalTime) you then need to make sure that the server recognizes it as UTC (it should do this automatically, but you may want to call SpecifyKind after receiving it just to be sure). The Entity Framework should then store this in the database unaltered – as you describe in your comment.

    Now the trick is to realise that the time you get back to the client when you retrieve the data will be in UTC. So when UK time no longer lines up with UTC it will appear wrong. So, make sure you call DateTime.ToLocalTime on any values you get back from the server before displaying them to the user.

    At least that’s the approach I would take.

    (Oh, and as a fellow UK developer I find it really useful to set the time on my client PC to anything but UK time when doing this kind of work – otherwise you’ll introduce bugs that you won’t pick up on until we shift over to BST. In my experience this tends to happen after you’ve gone live)

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

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I am trying to understand how to use SyndicationItem to display feed which is
I used javascript for loading a picture on my website depending on which small
I've got a string that has curly quotes in it. I'd like to replace
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I am reading a book about Javascript and jQuery and using one of the
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
I would like to run a str_replace or preg_replace which looks for certain words
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this

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.