|
-
Aug 31st, 2013, 10:27 PM
#1
Thread Starter
Frenzied Member
client/server datetime
Hi,
I'm having a little issue, currently my code, first it saves to DB then send an email in both codes it saves and send the current date and time. I use the following function to get the current date Now() . The problem is when it saves to DB, it saves the current time and date using the timezone of DB server location and the email send the date and time and appear in my wanted timezone (easter time zone). I was wondering if it's possible to make the also save to DB with the correct time zone without using any javascript.
thanks
-
Sep 2nd, 2013, 04:29 PM
#2
Thread Starter
Frenzied Member
Re: client/server datetime
I tried to convert from UTC to eastern time zone but I still end up with UTC time, not sure why.
Code:
Dim easternZone As TimeZoneInfo = TimeZoneInfo.FindSystemTimeZoneById("Eastern Standard Time")
Dim easternTime As DateTime = TimeZoneInfo.ConvertTimeFromUtc(Now.ToUniversalTime, easternZone)
Dim sigintime As DateTime = easternTime
-
Sep 12th, 2013, 02:26 PM
#3
Re: client/server datetime
If you need to have a database that will display local datetime to clients then you need to ALWAYS save the date in UTC format. Each client will have a timeoffset that you will have to calculate before sending. UTC time is always stored in GMT+0, so let's say your client has a timezone of -7, then all you have to do is to use a function DateAdd with HOURS and pass in the timeoffset. Also, if your database already contains data stored as SERVER DATE, then you can use what met0555 proposed to convert the server date to UTC date and then still use DateAdd to convert the date/time to clients datetime.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|