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
149
votes
14 answers

get UTC time in PHP

How can I get UTC/GMT +/- time stamp using PHP's date() function? For example, if I try date("Y-m-d H:i:s", time()); I will get Unix time stamp; but I need to get UTC/GMT time stamp with string GMT/UTC+/-0400 or GMT/UTC+/-1000 based on local…
Robin Michael Poothurai
  • 5,444
  • 7
  • 23
  • 36
149
votes
27 answers

Generating a drop down list of timezones with PHP

Most sites need some way to show the dates on the site in the users preferred timezone. Below are two lists that I found and then one method using the built in PHP DateTime class in PHP 5. I need help knowing which of these would be the best to…
Xeoncross
  • 55,620
  • 80
  • 262
  • 364
138
votes
19 answers

Entity Framework DateTime and UTC

Is it possible to have Entity Framework (I am using the Code First Approach with CTP5 currently) store all DateTime values as UTC in the database? Or is there maybe a way to specify it in the mapping, for example in this one for the last_login…
Fionn
  • 10,975
  • 11
  • 54
  • 84
138
votes
10 answers

Convert LocalDateTime to LocalDateTime in UTC

Convert LocalDateTime to LocalDateTime in UTC. LocalDateTime convertToUtc(LocalDateTime date) { //do conversion } I searched over net. But did not get a solution
skmaran.nr.iras
  • 8,152
  • 28
  • 81
  • 116
133
votes
20 answers

JSON Stringify changes time of date because of UTC

My date objects in JavaScript are always represented by UTC +2 because of where I am located. Hence like this Mon Sep 28 10:00:00 UTC+0200 2009 Problem is doing a JSON.stringify converts the above date to 2009-09-28T08:00:00Z (notice 2 hours…
mark smith
  • 20,637
  • 47
  • 135
  • 187
130
votes
19 answers

Python: Figure out local timezone

I want to compare UTC timestamps from a log file with local timestamps. When creating the local datetime object, I use something like: >>> local_time=datetime.datetime(2010, 4, 27, 12, 0, 0, 0, …
Adam Matan
  • 128,757
  • 147
  • 397
  • 562
117
votes
13 answers

Force Java timezone as GMT/UTC

I need to force any time related operations to GMT/UTC, regardless the timezone set on the machine. Any convenient way to so in code? To clarify, I'm using the DB server time for all operations, but it comes out formatted according to local…
SyBer
  • 5,407
  • 13
  • 55
  • 64
115
votes
3 answers

does System.currentTimeMillis() return UTC time?

I want to get the current UTC time in millis. I searched google and got some answers that System.currentTimeMillis() does returns UTC time. but it does not. If I do following: long t1 = System.currentTimeMillis(); long t2 = new…
g.revolution
  • 11,962
  • 23
  • 81
  • 107
114
votes
9 answers

How can I format DateTime to web UTC format?

I have a DateTime which I want to format to "2009-09-01T00:00:00.000Z", but the following code gives me "2009-09-01T00:00:00.000+01:00" (both lines): new DateTime(2009, 9, 1, 0, 0, 0, 0,…
Grzenio
  • 35,875
  • 47
  • 158
  • 240
109
votes
3 answers

MYSQL query / dates older than 1 week ago (all datetimes in UTC)

How do I query a mysql db to return all records with a datetime older than 1 week ago. Note that the datetime table stores everything in UTC, and I should be comparing it in that itself. Just to be clear - I'm looking for a pure mysql query.
tzmatt7447
  • 2,329
  • 9
  • 24
  • 31
108
votes
16 answers

php convert datetime to UTC

I am in need of an easy way to convert a date time stamp to UTC (from whatever timezone the server is in) HOPEFULLY without using any libraries.
Jeremey
  • 1,456
  • 3
  • 13
  • 19
104
votes
10 answers

get UTC timestamp in python with datetime

Is there a way to get the UTC timestamp by specifying the date? What I would expect: datetime(2008, 1, 1, 0, 0, 0, 0) should result in 1199145600 Creating a naive datetime object means that there is no time zone information. If I look at the…
pat
  • 2,600
  • 4
  • 20
  • 21
94
votes
11 answers

TSQL: How to convert local time to UTC? (SQL Server 2008)

We are dealing with an application that needs to handle global time data from different time zones and daylight savings time settings. The idea is to store everything in UTC format internally and only convert back and forth for the localized user…
BuschnicK
  • 5,304
  • 8
  • 37
  • 49
91
votes
7 answers

Is it always a good idea to store time in UTC or is this the case where storing in local time is better?

Generally, it is the best practice to store time in UTC and as mentioned in here and here. Suppose there is a re-occurring event let's say end time which is always at the same local time let's say 17:00 regardless of whether there is Daylight saving…
Sun
  • 2,110
  • 2
  • 21
  • 28
90
votes
2 answers

Best practices with saving datetime & timezone info in database when data is dependant on datetime

There were quite a few questions about saving datetime & timezones info in DB but more on the overall level. Here I'd like to address a specific case. System specs We have an Orders system database It is a multi-tenant system where tenants can use…
daneejela
  • 13,081
  • 7
  • 38
  • 50