Questions tagged [utc]

UTC stands for Coordinated Universal Time - it is the time standard by which the world regulates clocks and time.

UTC stands for Coordinated Universal Time - it is the time standard by which the world regulates clocks and time.

Questions relating to UTC can relate to date-time formatting, conversions etc.

Definition taken from - WikiPedia

2332 questions
2183
votes
30 answers

Daylight saving time and time zone best practices

I am hoping to make this question and the answers to it the definitive guide to dealing with daylight saving time, in particular for dealing with the actual change overs. If you have anything to add, please do Many systems are dependent on keeping…
Oded
  • 489,969
  • 99
  • 883
  • 1,009
831
votes
35 answers

How to convert a Date to UTC?

Suppose a user of your website enters a date range. 2009-1-1 to 2009-1-3 You need to send this date to a server for some processing, but the server expects all dates and times to be in UTC. Now suppose the user is in Alaska. Since they are in a…
dthrasher
  • 40,656
  • 34
  • 113
  • 139
524
votes
39 answers

Convert UTC date time to local date time

From the server I get a datetime variable in this format: 6/29/2011 4:52:48 PM and it is in UTC time. I want to convert it to the current user’s browser time zone using JavaScript. How this can be done using JavaScript or jQuery?
Amr Elgarhy
  • 66,568
  • 69
  • 184
  • 301
446
votes
10 answers

Why does datetime.datetime.utcnow() not contain timezone information?

datetime.datetime.utcnow() Why does this datetime not have any timezone info given that it is explicitly a UTC datetime? I would expect that this would contain tzinfo.
Vitaly Babiy
  • 6,114
  • 4
  • 26
  • 24
415
votes
26 answers

How to convert local time string to UTC?

How do I convert a datetime string in local time to a string in UTC time? I'm sure I've done this before, but can't find it and SO will hopefully help me (and others) do that in future. Clarification: For example, if I have 2008-09-17 14:02:00 in…
Tom
  • 42,844
  • 35
  • 95
  • 101
397
votes
17 answers

Convert UTC Epoch to local date

I have been fighting with this for a bit now. I’m trying to convert epoch to a date object. The epoch is sent to me in UTC. Whenever you pass new Date() an epoch, it assumes it’s local epoch. I tried creating a UTC object, then using setTime() to…
Shane Reustle
  • 8,633
  • 8
  • 40
  • 51
377
votes
11 answers

Converting datetime.date to UTC timestamp in Python

I am dealing with dates in Python and I need to convert them to UTC timestamps to be used inside Javascript. The following code does not work: >>> d = datetime.date(2011,01,01) >>>…
user2665694
346
votes
14 answers

Convert UTC/GMT time to local time

We are developing a C# application for a web-service client. This will run on Windows XP PC's. One of the fields returned by the web service is a DateTime field. The server returns a field in GMT format i.e. with a "Z" at the end. However, we found…
rbrayb
  • 46,440
  • 34
  • 114
  • 174
311
votes
16 answers

Convert UTC datetime string to local datetime

I've never had to convert time to and from UTC. Recently had a request to have my app be timezone aware, and I've been running myself in circles. Lots of information on converting local time to UTC, which I found fairly elementary (maybe I'm doing…
MattoTodd
  • 14,467
  • 16
  • 59
  • 76
298
votes
8 answers

Convert python datetime to epoch with strftime

I have a time in UTC from which I want the number of seconds since epoch. I am using strftime to convert it to the number of seconds. Taking 1st April 2012 as an example. >>>datetime.datetime(2012,04,01,0,0).strftime('%s') '1333234800' 1st of April…
Noel
  • 3,749
  • 3
  • 22
  • 21
229
votes
16 answers

How do I get a UTC Timestamp in JavaScript?

While writing a web application, it makes sense to store (server side) all datetimes in the DB as UTC timestamps. I was astonished when I noticed that you couldn't natively do much in terms of Timezone manipulation in JavaScript. I extended the Date…
Merc
  • 16,277
  • 18
  • 79
  • 122
212
votes
12 answers

How to set the timezone in Django

In my django project's settings.py file, I have this line : TIME_ZONE = 'UTC' But I want my app to run in UTC+2 timezone, so I changed it to TIME_ZONE = 'UTC+2' It gives the error ValueError: Incorrect timezone setting: UTC+2. What is the correct…
jeff
  • 13,055
  • 29
  • 78
  • 136
187
votes
5 answers

What is the difference between UTC and GMT?

I have a few queries regarding the Time zones: Can the time be captured in UTC alone? Is UTC -6 and GMT -6 the same, and does that mean it is US local time? Say, I have UTC time as "02-01-2018 00:03" does that mean my US local time is "01-01-2018…
Anagha
  • 3,073
  • 8
  • 25
  • 43
185
votes
6 answers

Should MySQL have its timezone set to UTC?

Follow up question of https://serverfault.com/questions/191331/should-servers-have-their-timezone-set-to-gmt-utc Should the MySQL timezone be set to UTC or should it be set to be the same timezone as the server or PHP is set? (If it is not UTC) What…
Timo Huovinen
  • 53,325
  • 33
  • 152
  • 143
163
votes
4 answers

C# DateTime to UTC Time without changing the time

How would I convert a preexisting datetime to UTC time without changing the actual time. Example: DateTime dateTime = GetSomeDateTime(); // dateTime here is 3pm dateTime.ToUtcDateTime() // datetime should still be 3pm
Luke Belbina
  • 5,708
  • 12
  • 52
  • 75
1
2 3
99 100