简体   繁体   中英

Using Dates in an MVC application

I have coded a MVC 5 internet application and have a question in regards to international dates.

I am wishing to add a create date field to each of my objects when my objects are saved into a SQL database. As this application will be used internationally, what format should I use for the dates and do I need to use a specific UTC?

Thanks in advance

The most common .NET type is DateTime. A DateTime stores a date and optionally a time. It has a Kind property which determines if the value is one of three: local, UTC, or unspecified. Another type is called DateTimeOffset. A DateTimeOffset stores a date and time relative to UTC. Additionally, it stores an offset from UTC as TimeSpan.

Console.WriteLine (DateTime.Now); // 1/28/2014 2:53:50 PM

Console.WriteLine (DateTimeOffset.Now); // 1/28/2014 2:53:50 PM -08:00

More Information : http://afana.me/post/aspnet-mvc-internationalization-date-time.aspx

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