locked
Getting the Server date, not the cleint RRS feed

  • Question

  • User157772347 posted

    hi,

    i develop a system which is issuing policies for travel insurance. i have a field for "Today" date. this field displays the today date in which the client issuing policies by, i want to get the server Date NOT the client side date because the client might change the date of his device and makes new policies.

    how to get the server side date ??

    thanks

    Tuesday, June 23, 2015 6:00 AM

Answers

  • User177399542 posted

    Hi ahmedsalahad

    When ever you extract date using DateTime it automatically returns you server date time.

    var myDate = DateTime.Now;

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, June 23, 2015 6:04 AM
  • User177399542 posted

    If your website is hosted on the server it will give you server datetime. No matter if user changes his/her system date time.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, June 23, 2015 6:19 AM

All replies

  • User177399542 posted

    Hi ahmedsalahad

    When ever you extract date using DateTime it automatically returns you server date time.

    var myDate = DateTime.Now;

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, June 23, 2015 6:04 AM
  • User157772347 posted

    Dear Anuj,

    i know this. but when i change my device Date, this will set the date to the device date. i want to get the real date of today on the server not getting it from the device the page is opened from.

    please, can you ??

    Tuesday, June 23, 2015 6:14 AM
  • User177399542 posted

    If your website is hosted on the server it will give you server datetime. No matter if user changes his/her system date time.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, June 23, 2015 6:19 AM
  • User753101303 posted

    Hi,

    This is just because currently the client machine and the server machine are the same one. Once deployed your server side C# code will run on a "real" web server. Not directly related by DateTime.UtcNow could be better (you'll get the same value, else it might depend on the local time of your hosting service).

    Tuesday, June 23, 2015 6:59 AM