Last post Jun 23, 2015 06:59 AM by PatriceSc
Jun 23, 2015 06:00 AM|ahmedsalahaddin|LINK
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 ??
Jun 23, 2015 06:04 AM|anuj_koundal|LINK
When ever you extract date using DateTime it automatically returns you server date time.
var myDate = DateTime.Now;
Jun 23, 2015 06:14 AM|ahmedsalahaddin|LINK
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 ??
Jun 23, 2015 06:19 AM|anuj_koundal|LINK
If your website is hosted on the server it will give you server datetime. No matter if user changes his/her system date time.
Jun 23, 2015 06:59 AM|PatriceSc|LINK
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).