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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T09:56:27+00:00 2026-05-25T09:56:27+00:00

Till today I am using DateTime.Now; function to save the time and data of

  • 0

Till today I am using DateTime.Now; function to save the time and data of users. Well, at later stage I used JavaScript to get the client’s date and time to maintain Time Zone. But when I change my system’s date and time and try that JavaScript. It show the changed time of my computer. I need how to get clients correct current date and time value. How to get it.

Please do not exceed answer more than C# & JavaScripts.

  • 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-25T09:56:28+00:00Added an answer on May 25, 2026 at 9:56 am

    On client, when client send a request with javascript, get new Date().toJSON() value and send it to server. toJSON() returns current client datetime in GMT+0000 timezone (Greenwich):

    var dtStr=new Date().toJSON();
    

    On server, in C#:

    DateTime dtServer=DateTime.Now;
    DateTime dtClient=DateTime.Parse(Request.QueryString["dtStr"]); // Or Request.Form
    double requestTimeDelta=10f; // max time in seconds between client starts the request,
                                 // and this code lines is executed.
    double secondsDelta=2f;
    DateTime max=dtClient.AddSeconds(requestTimeDelta+secondsDelta);
    DateTime min=dtClient.AddSeconds(-secondsDelta);
    if (max>=dtServer && min<=dtServer) {
      // time is correct
    }
    else
    {
      // time is incorrect
    }
    

    Above code is required, that time on client and on server has been synchronized with global clocks (internet timesource servers, for example). To avoid this problem you can calculate and save (in Session, for example) initial (on first request) difference between client and server clocks, and add this ‘difference’ to max and min variables. This behaviour is simply to coding, and not showed in code above.

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

Sidebar

Related Questions

Up till now we've been rewriting URL's using a custon 404 page: the url
I've been using RVM for quite some time now and have been very happy
Till now, I was using VB for developing applications. Now I have to use
till now i used in JSF 1.2 commandLinks and the setPropertyActionListener to pass for
I am php page everything was working fine till today morning. Now the page
Till now I had been using following code to ftp file from one location
Till this moment I used this method to invoke: public string AddText { set
Up till now I have been developing my personal and school projects at home
In all my projects till now, I use to use singleton pattern to access
I have till now mainly concentrated on web programming thus far and now want

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.