Questions tagged [timezone-offset]

A time zone offset describes the difference between a "wall time" and UTC. General questions about time zones will get better visibility when tagged with 'timezone'.

A time zone offset describes the difference between a "wall time" and UTC.

Time zones can change their offsets for many reasons, including daylight saving time. Therefore, an offset is not the same thing as a time zone, and It is only valid for the specific instant it is associated with.

General questions about time zones will get better visibility when tagged with .

See also the timezone tag wiki.

1036 questions
708
votes
27 answers

Determine a user's timezone

Is there a standard way for a web server to be able to determine a user's timezone within a web page? Perhaps from an HTTP header or part of the user-agent string?
Kevin Dente
  • 25,430
  • 7
  • 43
  • 47
241
votes
7 answers

javascript toISOString() ignores timezone offset

I am trying to convert Twitter datetime to a local iso-string (for prettyDate) now for 2 days. I'm just not getting the local time right.. im using the following function: function getLocalISOTime(twDate) { var d = new Date(twDate); var utcd…
Cyril Mestrom
  • 6,042
  • 4
  • 19
  • 27
216
votes
16 answers

How to check if DST (Daylight Saving Time) is in effect, and if so, the offset?

This is a bit of my JS code for which this is needed: var secDiff = Math.abs(Math.round((utc_date-this.premiere_date)/1000)); this.years = this.calculateUnit(secDiff,(86400*365)); this.days =…
Jo Smo
  • 6,923
  • 9
  • 47
  • 67
127
votes
2 answers

How to get default ZoneOffset in Java 8?

With Java 8 we know use ZoneId.default() can get system default ZoneId, but how to get default ZoneOffset? I see that a ZoneId has some "rules" and each rule has a ZoneOffset, is that means a ZoneId may have more than one ZoneOffset?
FredSuvn
  • 1,869
  • 2
  • 12
  • 19
92
votes
8 answers

git: timezone and timestamp format

From git I can get the timestamp: "2011-10-04 12:58:36 -0600" but is there any way to show it as: "2011-10-04 06:58:36" So all I want is to get rid of the -0600 timezone offset. How can I do this? Thanks.
SandyBr
  • 11,459
  • 10
  • 29
  • 27
71
votes
4 answers

Python pytz timezone function returns a timezone that is off by 9 minutes

For some reason which I haven't been able to figure out yet, from the the following code: >>> from pytz import timezone >>> timezone('America/Chicago') I get: When, I assume, I should…
elethan
  • 16,408
  • 8
  • 64
  • 87
68
votes
2 answers

Why does JavaScript Date.getTimezoneOffset() consider "-05:00" as a positive offset?

I noticed that for us on Eastern Time zone ("America/New_York") with timezone offset of "-05:00" Date.getTimezoneOffset() returns a positive number of 300. I would expect offset in minutes to be negative in areas to the West from Utc, and to be…
vkelman
  • 1,501
  • 1
  • 15
  • 25
48
votes
3 answers

Free Rest API to retrieve current datetime as string (timezone irrelevant)

I am seeking a reliable REST API that can provide world time and time zone information across platforms. I need the current time as a string. I'd like it to return the result in under a second, regardless of the user's location worldwide. Among…
chadoh
  • 4,343
  • 6
  • 39
  • 64
46
votes
2 answers

Identifying time zones in ISO 8601

No, I'm not talking about zone offsets --- those can vary during the year for a region based on e.g. DST. I'm talking about the actual time zones maintained by IANA. I understand these are not supported by ISO 8601, correct? What are platforms doing…
Garret Wilson
  • 18,219
  • 30
  • 144
  • 272
41
votes
4 answers

Java 8 Date and Time: parse ISO 8601 string without colon in offset

We try to parse the following ISO 8601 DateTime String with timezone offset: final String input = "2022-03-17T23:00:00.000+0000"; OffsetDateTime.parse(input); LocalDateTime.parse(input, DateTimeFormatter.ISO_OFFSET_DATE_TIME); Both approaches fail…
Ursin Brunner
  • 2,310
  • 1
  • 24
  • 24
40
votes
4 answers

Convert UTC to "local" time in Go

How can I convert UTC time to local time? I've created a map with the UTC difference for all the countries I need the local time. Then I add that difference as duration to the current time (UTC) and print the result hoping that's the local time of…
hey
  • 7,299
  • 14
  • 39
  • 57
38
votes
1 answer

Django default=timezone.now + delta

Trying to set a timestamp for a key expiration in Django model and bumped into this issue : My current code : key_expires = models.DateTimeField(default=timezone.now() + timezone.timedelta(days=1)) The code above works, however when…
Nerses
  • 709
  • 2
  • 9
  • 15
34
votes
3 answers

JavaScript check if timezone name valid or not

Is there a way to check if timezone name valid or not in JavaScript without using external library? When user enters timezone name in text field I want to verify whether zone is valid or not? I know we can do it easily using moment-timezone library.…
Pratap A.K
  • 4,337
  • 11
  • 42
  • 79
33
votes
3 answers

How can I extract the value of my current local time offset?

I'm struggling a bit trying to format and display some IBM mainframe TOD clock data. I want to format the data in both GMT and local time (as the default -- otherwise in the zone the user specifies). For this, I need to get the value of the local…
Brent.Longborough
  • 9,567
  • 10
  • 42
  • 62
31
votes
9 answers

Send PHP date to JavaScript date format

I want to pass my PHP server time to my JavaScript file. PHP Code: date_default_timezone_set('Australia/Perth'); echo date("r"); JavaScript: $.get('time.php', function(data) { today = new Date(data); closing = new Date(data); }); The PHP code…
jribeiro
  • 3,387
  • 8
  • 43
  • 70
1
2 3
68 69