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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T10:36:27+00:00 2026-05-26T10:36:27+00:00

How do I get the JavaScriptSerializer from System.Web.Extensions to use CultureInfo.CurrentCulture? I’m getting exceptions

  • 0

How do I get the JavaScriptSerializer from System.Web.Extensions to use CultureInfo.CurrentCulture?

I’m getting exceptions deserializing DD/MM/YYYY DateTimes, as it’s currently expecting them in US format, which is incorrect for our application.

  • 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-26T10:36:28+00:00Added an answer on May 26, 2026 at 10:36 am

    Per the MDSN notes on JavaScriptSerializer:

    Date object, represented in JSON as “/Date(number of ticks)/”. The number of ticks is a positive or negative long value that indicates the number of ticks (milliseconds) that have elapsed since midnight 01 January, 1970 UTC.

    The maximum supported date value is MaxValue (12/31/9999 11:59:59 PM) and the minimum supported date value is MinValue (1/1/0001 12:00:00 AM).

    You’ll need to register a JavaScriptConverter for DateTime that handles your type:

    public class DateTimeConverter : JavaScriptConverter
    {
    
        public override object Deserialize(IDictionary<string, object> dictionary, Type type, JavaScriptSerializer serializer)
        {
            if (dictionary == null)
                throw new ArgumentNullException("dictionary");
    
            if (type == typeof(DateTime))
            {
                DateTime time;
                time = DateTime.Parse(dictionary["Time"].ToString(), /** put your culture info here **/);
    
                return time;
            }
    
            return null;
        }
    
        public override IDictionary<string, object> Serialize(object obj, JavaScriptSerializer serializer)
        {
            DateTime? time = obj as DateTime?;
    
            if (time == null)
            {
                Dictionary<string, object> result = new Dictionary<string, object>();
                result["Time"] = time.Value;
    
                return result;
            }
    
            return new Dictionary<string, object>();
        }
    
        public override IEnumerable<Type> SupportedTypes
        {
            get { return new ReadOnlyCollection<Type>(new List<Type>(new Type[] { typeof(DateTime) })); }
        }
    }
    

    Bear in mind you’ll need to account for what your JSON will actually have in terms of object property names (you’re probably using a name other than “Time”).

    Register it on your JavaScriptSerializer:

    serializer.RegisterConverters(new List<JavaScriptConverter>() { new DateTimeConverter() });
    

    Finally, note that there’s more that can be done, and this is only an example to build on. Explicitly, it is searching for dictionary items with the name “Time”, and isn’t handling parse failures. You might have more than just one name for fields using DateTime.

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

Sidebar

Related Questions

I get an XML file From a web service. Now I want to get
I am using the System.Web.Script.Serialization.JavaScriptSerializer contained in System.Web.Extentions DLL. I have several circular references
I need to get Json data from a C# web service. I know there
The javascript does not get value from the web method. It says undefined for
We get a large amount of data from our clients in pdf files in
I get an Access is Denied error message when I use the strong name
I get a URL from a user. I need to know: a) is the
SO I am getting a response from the google translate API's like this: {\responseData\:
I get the Json from google. it has many details on many things but
I get an error of Cannot convert object of type System.String' to type 'System.Collections.Generic.List'1[...+ContactHolder]'

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.