简体   繁体   中英

How do I set DateTimes universally to local time in view engine?

I am storing DateTimes in my db using UniversalTime. In my views/controllers, I was hoping to convert them to Local Time. Is there a way to do this other than calling.ToLocalTime() in my controller on each individual DateTime?

You could write a custom display template for DateTime .

@model System.DateTime

@Model.ToLocalTime()

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM