timezone-offset

PHP & MySQL: Converting Stored TIMESTAMP into User's Local Timezone

北城以北 提交于 2019-11-27 21:26:50
So I have a site with a comments feature where the timestamp of the comment is stored in a MySQL database. From what I understand, the timestamp is converted to UTC when stored, then converted back to the default timezone when retrieved. In my case, my server is in the Central Daylight Time timezone (CDT). I have a plan to get the timezone from each user via entry form. I just wanted to know how to convert the TIMESTAMP value into the user's timezone. First, would I convert from UTC to local timezone? Or CDT to local timezone? Secondly, how would I go about doing that in PHP? Would I just do:

Java 8 timezone conversions

痞子三分冷 提交于 2019-11-27 09:05:34
In Java 8, I want to convert a datetime from UTC to ACST (UTC+9:30). input -> 2014-09-14T17:00:00+00:00 output-> 2014-09-15 02:30:00 String isoDateTime = "2014-09-14T17:00:00+00:00"; LocalDateTime fromIsoDate = LocalDateTime.parse(isoDateTime, DateTimeFormatter.ISO_OFFSET_DATE_TIME); ZoneOffset offset = ZoneOffset.of("+09:30"); OffsetDateTime acst = OffsetDateTime.of(fromIsoDate, offset); System.out.println(acst.toString()); // 2014-09-14T17:00+09:30 System.out.println(acst.format(DateTimeFormatter.ISO_OFFSET_DATE_TIME)); // 2014-09-14T17:00:00+09:30 Why is the offset not performed? Try:

git: timezone and timestamp format

不想你离开。 提交于 2019-11-27 08:32:45
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. Lazy Badger If you ask about git log, you can try and select most correct form from: git log --date={relative,local,default,iso,rfc} --date=local seems to be the best candidate. To make this permanent, use git config --global log.date local . git log --date=local Does the trick. git config --global log.date local Christian TZ=UTC git log --date=local in order to get non-local-timezone one

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

泪湿孤枕 提交于 2019-11-27 01:00:39
问题 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 positive in areas to the east of Utc, but apparently it's "flippded". What's the reasoning behind that decision? http://momentjs.com/ follows the same rule and returns... moment.parseZone("01/13/2014 3:38:00 PM +01:00").zone() // == -60 moment

Google Apps Script formatDate using user's time zone instead of GMT

假装没事ソ 提交于 2019-11-26 21:33:38
问题 I have a line that sets the current date and time in a cell: sheet.getRange(1,1).setValue(new Date()); Then I have a line that creates a formatted date based on that cell's value: var addedDate = sheet.getRange(1,1).getValue(); var addedTime = Utilities.formatDate(addedDate, "GMT", "hh:mm a"); The resulting addedTime seems to be in the GMT time zone and I need it to be in the user's time zone. It will usually be US Eastern Time (-0500), but if I simply subtract 5 hours from the time then that

PHP & MySQL: Converting Stored TIMESTAMP into User's Local Timezone

风流意气都作罢 提交于 2019-11-26 20:39:59
问题 So I have a site with a comments feature where the timestamp of the comment is stored in a MySQL database. From what I understand, the timestamp is converted to UTC when stored, then converted back to the default timezone when retrieved. In my case, my server is in the Central Daylight Time timezone (CDT). I have a plan to get the timezone from each user via entry form. I just wanted to know how to convert the TIMESTAMP value into the user's timezone. First, would I convert from UTC to local

javascript toISOString() ignores timezone offset

拥有回忆 提交于 2019-11-26 19:35:07
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 = Date.UTC(d.getFullYear(), d.getMonth(), d.getDate(), d.getHours(), d.getMinutes(), d.getSeconds(), d.getMilliseconds()); // obtain local UTC offset and convert to msec localOffset = d.getTimezoneOffset() * 60000; var newdate = new Date(utcd + localOffset); return newdate.toISOString().replace(".000", ""); } in newdate everything is ok but the toISOString

git: timezone and timestamp format

生来就可爱ヽ(ⅴ<●) 提交于 2019-11-26 17:45:51
问题 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. 回答1: If you ask about git log, you can try and select most correct form from: git log --date={relative,local,default,iso,rfc} --date=local seems to be the best candidate. To make this permanent, use git config --global log.date local . 回答2: git log --date=local Does the trick. git config -

Convert UTC offset to timezone or date

浪尽此生 提交于 2019-11-26 17:35:15
A head scratcher for you. I am grabbing geo IP data from IPInfoDB 's API and it returns a timezone offset from UTC including DST (if currently reflected). For example, I live in EST (-5) and currently it's DST, so the geo IP API returns ( -04:00 ) as the offset. This is wonderful since DST is a freaking headache. But to my surprise, it caused another headache. I load this data in PHP to be passed via AJAX to the application. I would like to have the live local time of the IP address on the app. I have that all set perfectly, but I am going crazy trying to figure out how to set the PHP timezone

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

拜拜、爱过 提交于 2019-11-26 16:40:38
This question already has an answer here: Cannot parse String in ISO 8601 format, lacking colon in offset, to Java 8 Date 1 answer 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 (which makes sense as OffsetDateTime also use the DateTimeFormatter.ISO_OFFSET_DATE_TIME ) because of the colon in the timezone offset. java.time.format.DateTimeParseException: Text '2022-03-17T23:00:00.000+0000' could