Results 1 to 3 of 3

Thread: client/server datetime

  1. #1

    Thread Starter
    Frenzied Member met0555's Avatar
    Join Date
    Jul 2006
    Posts
    1,385

    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

  2. #2

    Thread Starter
    Frenzied Member met0555's Avatar
    Join Date
    Jul 2006
    Posts
    1,385

    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

  3. #3
    Serge's Avatar
    Join Date
    Feb 1999
    Location
    Scottsdale, Arizona, USA
    Posts
    2,744

    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
  •  



Click Here to Expand Forum to Full Width