How to convert PST to UTC Click on the PST field (left) and select the time you want to convert to UTC. The time in UTC (right) will be updated automatically. PDT is 7 hours behind of UTC. If you are in PDT, the most convenient time to accommodate all parties is between 9:00 am and 11:00 am for a conference call or meeting. In UTC, this will be a usual working time of between 4:00 pm and 6:00 pm.
Recently we needed to convert all dates in our database to UTC format. We've made a mistake not storing them in UTC from the beginning and it led to complicated issues. When you have to support various time zones, there is no other way but to store you dates in UTC.
Universal Time and Pacific Daylight Time Converter Calculator, UTC and PDT Conversion Table. Coordinated Universal Time (UTC) is the primary time standard now, time zones around the world are expressed using offsets from UTC, UTC offset is the difference in hours and minutes from UTC, a time zone can be determined by adding or subtracting the number of UTC offset. Support daylight saving time (DST) or summer time.
Luckily enough SQL Server comes with a handy GETUTCDATE() function, which, as you all have guessed, returns the current UTC date. The only thing you need to know to convert your dates to UTC is the offset between your server's time and UTC. You can do it like this:
For Eastern Standard Time that will be -5. So to convert your dates to UTC you need to do this:
But there is one problem.
Currently the offset between UTC and EST is actually -4, since it's summer and we are now in daylight savings time (EDT). So the above code will substract 4 hours from every date we have. But obviously lots of those past dates are not during daylight savings and you need to substract full five hours from them. Turns out there is really no way around that in SQL Server.
But you can perform the converion outside of SQL. .NET has great built in tools to convert between time zones with daylight savings support. It is really easy to do the conversion in C#:
Then you just need to store it in the database and you are all set. You can even create a CLR stored procedure out of that method. Hopefully all of the above will save you some time.
Max Al Farakh
Max is a co-founder/CTO of Jitbit with tons of experience in customer service.