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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T13:02:30+00:00 2026-05-25T13:02:30+00:00

I serialized an object containing current date in DateTimeOffset data type using DataContractJsonSerializer. This

  • 0

I serialized an object containing current date in DateTimeOffset data type using DataContractJsonSerializer. This is what I get as output:

<root type="object">
<blah type="object">
<DateTime>/Date(1315565372414)/</DateTime>
<OffsetMinutes type="number">300</OffsetMinutes>
</blah>
</root>

How do I make sense of this? How do I convert the number 1315565372414 back to a date?
My client is receiving this thing in python and would want to change it back to date.
I’m not sure if these are ticks or seconds since epoch but both of them yield incorrect result.
Following is my code in .net to convert it back but the results are absurd

Console.WriteLine(new DateTime(1970, 1, 1).AddTicks(1315565372414));

If I try AddSeconds; it throws value out of range exception.

Here is how I’m serializing the date:

[DataContract]
public class Test
{
    [DataMember]
    public DateTimeOffset blah { get; set; }
}

    var serializer = new DataContractJsonSerializer(typeof(Test));
    var writer = new StringWriter();
    serializer.WriteObject(new XmlTextWriter(writer), new Test() { blah = DateTimeOffset.Now });
    string output = writer.ToString();

    Console.WriteLine(output);
  • 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-25T13:02:31+00:00Added an answer on May 25, 2026 at 1:02 pm

    It is number of miliseconds since epoch. To deserialize it we need to do following:

    var date = new DateTime(1970, 1, 1).AddMilliseconds(1315565098519);
    var dateWithOffset = new DateTimeOffset(date, TimeSpan.FromMinutes(300));
    

    References:

    • http://www.w3schools.com/js/js_obj_date.asp
    • http://msdn.microsoft.com/en-us/library/bb412170.aspx
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to store an xml serialized object in a cookie, but i get
How do you return a serialized JSON object to the client side using ASP.NET
I have an object graph serialized to xaml. A rough sample of what it
I want to set some attributes just before the object is serialized, but as
I have a pretty sizeable object graph that I have serialized to a file
I have an object that is mapped to a cookie as a serialized base-64
I'm trying to pass a complex object (that can be serialized, if that helps)
I am using Telerik controls in my webforms and want to serialize object on
I'm using VB.Net, and I have a set of data which I have to
There are two assemblies: 1) Assembly containing serializer. This is a place from where

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.