updatesbion.blogg.se

Utc time to pst converter
Utc time to pst converter




utc time to pst converter

You can download the applicable functions and data from The Code Project If you do not need exact times in your data, and if you are only ever converting from Pacific to UTC and not other time zones, then you can use the method John suggested.įor better accuracy, you can create a table in your database which stores the time zones and when each country switches to daylight savings. Depending on how far back you go, the dates and rules for determining the dates Daylight Saving Time started and ended have changed many times over the years.Īnyone know of a function I can use to convert the UTC date/time field to Pacific Time? I know I can use dateadd to subtract the 8 hours, but I would like to know if there is a better way. A web search should turn up the basic data for you. For an application that looks at historic times and needs to convert any from UTC to Pacific Time, I'd think you'll need a table of the start and end dates for Daylight Saving Time to know whether it's -7 hours or -8 hours. Of course, the current difference (-7) may not be valid if you're looking at a date from February, for instance. ,DateAdd(hh,DATEDIFF(hh, GetUtcDate(), GetDate()), as MyDatePacific If your server is set to the Pacific time you want (standard or daylight), you may use the DateDiff between getDate() and getUTCDate() as your offset, using DateAdd to apply it to your UTC time. But of course you also will probably want to account for whether daylight saving time is in effect, making the difference -7 hours rather than -8. Knowing your time zone (Pacific) is a good start.






Utc time to pst converter