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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T14:43:10+00:00 2026-05-16T14:43:10+00:00

I have a page that displays data from an object. I’m loading the object

  • 0

I have a page that displays data from an object. I’m loading the object server side, and passing the results through an AJAX call with json. There is a date property that is part of the object. For some reason, the date is being changed. It looks like it is trying to take into account the timezone I’m in and subtracting 4 hours from the date (I’m in EST, -4 difference from GMT).

When I click a “Display” button for a message, it makes an AJAX call to load the data for that message, and then displays it.

Here’s my javascript code:

function onBtnDisplayClicked(id)
{
    $.ajax({
        type: "POST",
        url: "<%= Url.Action("GetMessage") %>?id=" + id.toString(),
        success: function(data) { bindItem(data); },
        dataType: "json",
        contentType: "application/json; charset=utf-8"
    });
}


function bindItem(data) 
{
    $("#MessageID").val(data.MessageID);

    //Create a Date object from JSON date format - ex: (1230807660000-4000)
    var messageDate = new Date(parseInt(data.MessageDate.replace(/\/Date\((\d+)\)\//, '$1')));

    //Format date using DateFormat plugin (http://jacwright.com/projects/javascript/date_format)
    $("#txtMessageDate").val(messageDate.format('m/d/Y H:i'));
}

And here’s my server side code:

public JsonResult GetMessage(int id)
{
    Message msg = new Message();
    msg.LoadByPrimaryKey(id);

    var data = new
    {
        MessageID = msg.MessageID.Value,
        MessageDate = msg.MessageDate.Value
    };

    return new JsonResult() { Data = data };
}

This will work correctly on my local environment, but not on my production environment. In my local environment, the server time is set to EST (2:00 PM). On production, the server time is set to GMT (6:00 PM).

So if I’m trying to display “09/01/2010 09:00 AM”, it will display correctly on my local environment, but on production it displays as “09/01/2010 05:00 AM”. I’m not sure why it’s doing this.

  • 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-16T14:43:11+00:00Added an answer on May 16, 2026 at 2:43 pm

    It is likely doing this because it knows what timezone the date is coming from, so technically speaking they both represent the same point in time with regards to your timezone…

    I’m not entirely sure how you would do it, but you need to override the timezone used when formatting the string when presenting the date to the UI. If you have access to the code in that DateTime plugin, then I suspect this is the place to address the problem.

    Sorry its not a practical answer; I only get the theory as I have little to no JSON/AJAX experience these days.

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

Sidebar

Related Questions

I have a simple php page that displays data from a mysql database. I
I have a web page that displays dynamic data which changes every 2 seconds.
I have a page that displays search results and has a DOM like the
I have a html page that calls a php object to get some data
I have a page that displays hotel data in a list. I have this
I have a View with a form which displays data from objects that are
I have a page that displays a list with a of elements with a
I have a page that displays a table in two different modes. In each
i have a page that displays large datasets into html tables. how can i
I have a page that displays messages and I want it to work just

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.