asp.net mvc - Convert UTC time to Client browser's timezone using JavaScript in a MVC View -


i have module in website logged in users can post comments on article. saving utc time posted time in database. per requirement need display posted time comment , time difference between posted time , current time (for example last seen in facebook or comment posted time in facebook) comment. posted time must show in client browser's timezone.

for e.g: user xyz has commented on 01:00 utc, ,

  • if account of xyz logged in india timezone must india time zone (utc+05:30) , time appear 6:30 am.

  • if account of xyz logged in singapore timezone must singapore time zone(utc+8:00) , time appear 9:00 am.

to achieve above have searched on web , found post get client time zone browser helpful client browser's timezone. (which not able test yet if convert time correctly or not)

now main issue convert utc time given timezone (which getting using solution mentioned here get client time zone browser).

please share suggestions.

if name of timezone, can time utc this:

var utc = datetime.utcnow; var tz = timezoneinfo.findsystemtimezonebyid("the timezone"); return timezoneinfo.converttimefromutc(utc, tz); 

hope helps.


Comments

Popular posts from this blog

javascript - Jquery show_hide, what to add in order to make the page scroll to the bottom of the hidden field once button is clicked -

javascript - Highcharts multi-color line -

javascript - Enter key does not work in search box -