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 7702071
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T23:08:32+00:00 2026-05-31T23:08:32+00:00

This is a very simple, (hopefully) question. I am new to working with DateTime

  • 0

This is a very simple, (hopefully) question. I am new to working with DateTime conversion in .NET.

I have a WCF service which has a DateTime property – call it BookingDate.

Someone passes that to my WCF service in the format:

<a:BookingDate>2012-03-26T17:03:00-04:00</a:BookingDate>

The server that it is sitting on is set to a timezone of UTC (Lisbon, London, Dublin).

When I store the corresponding value in the database, it sets the value to be:

2012-03-26 22:03

I assumed, I think incorrectly that the .NET framework (as part of the WCF serialize/deserialize process) would pop this into a .Net Datetime of UTC for me (as there is the minus offset of 4 hours as above)

I was expecting: 2012-03-26 21:03

My question is thus: would I need to call:

var date = fromClientWCFService.BookingDate.ToUniversalTime();

in order to get the 21:03 time that I am expecting?

If not, is there a WCF setting to tell my service to convert DateTimes to UTC, rather than the server timezone?

Thanks in advance

Mark

EDIT:

From 1 answer, I can see that DateTimeOffset can be used. Following on from this, would the following work: var offset = DateTimeOffset.Parse("2012-03-26T17:03:00-0400"); to return the result: 2012-03-26 21:03

  • 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-31T23:08:33+00:00Added an answer on May 31, 2026 at 11:08 pm

    Instead of using the DateTime structure, you should use the DateTimeOffset structure.

    The DateTimeOffset structure captures the offset from a specified time (it’s not UTC by default, it’s defined by the scope of your application, but the most common offset would be from UTC) along with the date/time information, and that information will flow through WCF calls (as well as to a database, assuming it supports the type. SQL Server in this case has the datetimeoffset data type from 2008 on).

    As a matter of fact, using DateTimeOffset is the preferred methods of dealing with date/time data in almost all situations. Note from the previous link:

    These uses for DateTimeOffset values are much more common than those
    for DateTime values. As a result, DateTimeOffset should be considered
    the default date and time type for application development.

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

Sidebar

Related Questions

This is hopefully a very simple question, but one a lot of Googling has
This isn't a very simple question, but hopefully someone has run across it. I
This is hopefully a very simple maths question. If I have two number ranges,
Hopefully this is a very simple question. I have a makefile pattern rule that
Hopefully this is a very simple question. Following is the C pgm (test.c) I
Hopefully this is very simple. I have a central activity that can be launched
I have this very simple example that I am using to learn structs in
I have this very simple sql statement: SELECT max_dose FROM psychotropes WHERE (patient_meds.psychotrope =
I have this very simple C++ class: class Tree { public: Node *head; };
I'm sure this is very simple. I have gotten colorbox to work before, but

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.