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
50
votes
5 answers

How to convert DateTime in Specific timezone?

I find it hard to understand how UTC works. I have to do the following but I'm still confused if I'd get the right result. Objectives: Ensure all saved dates in Database are in UTC format Update DefaultTimezone is in Manila time Ensure…
fiberOptics
  • 6,955
  • 25
  • 70
  • 105
50
votes
4 answers

pytz utc conversion

What is the right way to convert a naive time and a tzinfo into an UTC time? Say I have: d = datetime(2009, 8, 31, 22, 30, 30) tz = timezone('US/Pacific') First way, pytz inspired: d_tz = tz.normalize(tz.localize(d)) utc =…
Art
  • 23,747
  • 29
  • 89
  • 101
48
votes
6 answers

Getting current GMT time

Is there a method in C# that returns the UTC (GMT) time zone? Not based on the system's time. Basically I want to get the correct UTC time even if my system time is not right.
user62958
  • 4,669
  • 5
  • 32
  • 35
47
votes
4 answers

Python Datetime : use strftime() with a timezone-aware date

Suppose I have date d like this : >>> d datetime(2009, 4, 19, 21, 12, tzinfo=tzoffset(None, -7200)) As you can see, it is "timezone aware", there is an offset of 2 Hour, utctime is >>> d.utctimetuple() time.struct_time(tm_year=2009, tm_mon=4,…
snoob dogg
  • 2,491
  • 3
  • 31
  • 54
46
votes
6 answers

Creating a DateTime object with a specific UTC DateTime in PowerShell

I'm trying to create a DateTime object with a specific UTC timestamp in PowerShell. What's the simplest way to do this? I tried: Get-Date -Format (Get-Culture).DateTimeFormat.UniversalSortableDateTimePattern -Date "1970-01-01 00:00:00Z" but…
sourcenouveau
  • 29,356
  • 35
  • 146
  • 243
45
votes
7 answers

Best way to compare dates without time in SQL Server

select * from sampleTable where CONVERT(VARCHAR(20),DateCreated,101) = CONVERT(VARCHAR(20),CAST('Feb 15 2012 7:00:00:000PM' AS DATETIME),101) I want to compare date without time Is above query is ok? or other better solution you suggest I…
Ali
  • 3,545
  • 11
  • 44
  • 63
45
votes
5 answers

Java Date to UTC using gson

I can't seem to get gson to convert a Date to UTC time in java.... Here is my code... Gson gson = new GsonBuilder().setDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'").create(); //This is the format I want, which according to the ISO8601 standard - Z…
Marky0
  • 1,984
  • 2
  • 12
  • 28
45
votes
1 answer

How to get an UTC date string in Python?

I am trying to get utc date string as "YYYYMMDD" For now I do the following, nowTime = time.gmtime(); nowDate = date(nowTime.tm_year, nowTime.tm_mon, nowTime.tm_mday) print nowDate.strftime('%Y%m%d') I used to…
GJain
  • 5,025
  • 6
  • 48
  • 82
44
votes
4 answers

How to specify that DateTime objects retrieved from EntityFramework should be DateTimeKind.UTC

I have C# program where all DateTime objects are DateTimeKind.UTC. When saving the objects to the database it stores UTC as expected. However, when retrieving them, they are DateTimeKind.Unspecified. Is there a way to tell Entity Framework (Code…
William
  • 1,354
  • 3
  • 13
  • 18
42
votes
4 answers

How does the (Oracle) Java JVM know a leap second is occurring?

A leap second will occur on June 30, 2015. Different Operating Systems seem to handle this situation differently. In my particular case, we are running a Red Hat 6.4 system with custom Java (JDK 1.7) software that is heavily time-dependent. …
Ogre Psalm33
  • 21,366
  • 16
  • 74
  • 92
40
votes
3 answers

Cache.Add absolute expiration - UTC based or not?

The examples for Cache.Add uses DateTime.Now.Add to compute the expiration, i.e. it passes: DateTime.Now.AddSeconds(60) as the value of the absoluteExpiration parameter. I'd have thought that computing it relative to DateTime.UtcNow would be more…
Ruben Bartelink
  • 59,778
  • 26
  • 187
  • 249
40
votes
4 answers

GMT vs UTC dates

I have a calendar built in JavaScript that compares dates with PHP. The JavaScript date object is set using PHP, but, when I compare future dates, they appear to be out of sync. PHP is set to GMT and JavaScript is set to UTC; how do these standards…
Tom
  • 1,651
  • 3
  • 19
  • 19
40
votes
5 answers

Javascript JSON Date parse in IE7/IE8 returns NaN

I'm parsing a date from a JSON event feed - but the date shows "NaN" in IE7/8: // Variable from JSON feed (using JQuery's $.getJSON) var start_time = '2012-06-24T17:00:00-07:00'; // How I'm currently extracting the Month & Day var d = new…
Josiah
  • 1,117
  • 5
  • 22
  • 35
39
votes
7 answers

Convert UTC to current locale time

I am downloading some JSON data from a webservice. In this JSON I've got some Date/Time values. Everything in UTC. How can I parse this date string so the result Date object is in the current locale? For example: the Server returned "2011-05-18…
LongFlick
  • 1,129
  • 1
  • 12
  • 21
39
votes
6 answers

Converting an ISO 8601 timestamp into an NSDate: How does one deal with the UTC time offset?

I'm having trouble converting an ISO 8601 timestamp into an NSDate. I tried to use NSDateFormatter, but I can't get it to work with the UTC time offset that appears on the end of the timestamps. To explain, I would like to convert a timestamp such…
EJV
  • 1,009
  • 1
  • 10
  • 17