Iron Speed Technical Forums
Sign up Latest Topics
 
 
 


Reply
  Author   Comment  
jtroska

Registered:
Posts: 3
Reply with quote  #1 
I need to date/time stamp for audit purposes. However my issue is that my server hosting the application and users are in different time zones. The database uses the host server for date/time stamp for the insert of new record. The question I have is how can I continue to use the host server's date/time versus the end user's local time for an update to a record? The only options in ISD I see are for using the end user's local time.
JimiJ

Avatar / Picture

MVP Developer
Registered:
Posts: 1,966
Reply with quote  #2 
You can use TimeZoneInfo class to convert UTC DateTime to Local DateTime:
http://stackoverflow.com/questions/9869051/how-to-convert-datetime-in-specific-timezone

You may use also DateTimeOffset To Local Time:
http://msdn.microsoft.com/en-us/library/system.datetimeoffset.tolocaltime.aspx



Jimi J

__________________

  Jaime Jegonia
[jts_logo]

Iron Speed MVP Developer
 

". . . and whoever sows generously will also reap generously" 2 Cor 9:6

timt

Avatar / Picture

Iron Speed MVP
Registered:
Posts: 556
Reply with quote  #3 
Hi

Jimmi mentions some great resources. Its not as straight forward as it should be (what is?). You have to determine the Timezone on the client which requires some javascript. There are routines out there which help. You then need (probably) to convert to .Net timezone values.

You need to always store UTC time in the database so check that there are no db defaults of gettime(), they all need to be the UTC variants of getetime. In your code do not use Datetime.Today, use the UTC version. (ToUtcDateTime etc)

You then need to ensure that dates are timezone converted before displaying. I have spent some time researching this and ended up modifiying the baseclasees DB date class to achieve this.

I hope to write it up one day as its complicated to completely automate this.

HTH

__________________
Tim Titchmarsh Iron Speed Consultant MVP
London UK based
+44 (0)1621 835002
http://www.lightspeeditsolutions.co.uk/dotnetarchitect
timt@dotnetarchitect.co.uk
timt@lsits.co.uk
Charax

Avatar / Picture

Registered:
Posts: 71
Reply with quote  #4 

For adding a UtcNow() function to Iron Speed, please see:

http://sjc.ironspeed.com/post/Time-Zones...-again-6087314

I suggested this essential function be added to ISD 10, but it doesn't seem to have made the cut.

Cheers,

Charax
Previous Topic | Next Topic
Print
Reply

Quick Navigation:

Easily create a Forum Website with Website Toolbox.

Download Iron Speed Designer

Terms of Service Privacy Statement