asp.net - Converting dates in C# -


i have asp.net mvc app not converting dates values properly. reside in 1 time zone. users resides in another. @ time, assume have following string:

var date = "7/1/2014 4:00:00 +00:00"; 

i converting string datetime using following:

datetime temp; if (datetime.tryparse(date, out temp)) {     temp = temp.toshortdatestring();     writetolog(temp); } 

when temp written log file, see being written 6/30/2014. possibly cause this? i'm expecting 7/1/2014. works on machine. however, not working on users machine.

the answer timezones. you're parsing specific point in time (4:00 am, gmt). same point in time 10:00 pm cst day before.

if keep in utc:

var s = temp.touniversaltime().toshortdatestring(); 

you'll requested output.


Comments

Popular posts from this blog

python - TypeError: start must be a integer -

c# - DevExpress RepositoryItemComboBox BackColor property ignored -

django - Creating multiple model instances in DRF3 -