简体   繁体   中英

UTC DateTime back to Original datetime

I have probably just stared at this too long...

I have a third-party datepicker (ASP/MVC) and I stringify the array of selected dates and pass it to the controller.

example:

  • My browser is US EST time zone.
  • I select 5/21/2013
  • when I stringify it I get ["2013-05-21T04:00:00Z"] (UTC)
  • I pass it back to the webserver that is in Us PST timezone
  • I want to get it back to 5/21/2013 12:00:00AM

I know that this is meant to be midnight since it is from a timeless datepicker.

In c#, how do I convert this back to its original time? I am in PST but that should not matter.

Try

string date = "2013-05-21T04:00:00Z" ;
DateTime dt = Datetime.parse(date);
dt = dt.Date;

You will get the date component only, with the time component as midnight. I hope this satisfies your requirement.

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