Mian Bilal
Mian Bilal

Reputation: 3

Facing issue with datetime.now in mvc5

i am using Dateime.Now in .net mvc and i deployed my website on europen web server when i use date someware in my website system always pick server datetime which is not best for me i want system always pick specific user coutry datettime if user locate in pakistan syetem always pick pakistan datetime or if user locate in japan system always pick japan datetime is this possiable?

Upvotes: 0

Views: 80

Answers (1)

Gabriel Llorico
Gabriel Llorico

Reputation: 1803

save/create the datetime in the backend as DateTime.UtcNow to set it in utc and in the frontend convert it to local via javascript

new dateToLocal = new Date(dateTimeValueFromServer);
document.getElementById(idOfDateTimeElement).value = dateToLocal;

Upvotes: 2

Related Questions