timezone

Java - Convert From A Timezone Different From Local To UTC

[亡魂溺海] 提交于 2019-12-11 11:55:30
问题 So from all the posts I read about this issue (for example, Convert timestamp to UTC timezone). I learn that a way to do this conversion is : SimpleDateFormat dfmaputo = new SimpleDateFormat("MM/dd/yyyy HH:mm:ss a"); dfmaputo.setTimeZone(TimeZone.getTimeZone("UTC")); long unixtime = dfmaputo.parse(data.get(1)).getTime(); unixtime = unixtime / 1000; output: original date (Maputo Timezone) -- 11/5/2015 1:39:45 PM unix timestamp in UTC --- 1446687585 data.get(1) is the string with the maputo

Does Facebook's login API update the timezone offset depending on whether DST is used in a user's area?

我与影子孤独终老i 提交于 2019-12-11 11:54:03
问题 When I output the facebook's user data [my facebook acc's] $user = $this->facebook->api('/me'); print_r($user); it gives -7, which is correct, but does it account for when DST is in effect? like when DST is in effect AND if my location uses DST, does FB update/change the offset accordingly? [timezone] => -7 [locale] => en_US 回答1: Facebook's documentation explains that the timezone field is the user's timezone offset from UTC. What it doesn't make clear, but I have found through

How to provide an elegant time zone picker?

那年仲夏 提交于 2019-12-11 11:34:31
问题 Update: I lean towards extracting data from Wikipedia and creating the picker myself: List of time zones by country and daylight saving time by country. It still has some issues: I don't get all official names of the time zones and I have to provide for daylight saving times myself. Also providing different languages might be a problem. I want the users of my web site to be able to pick their time zone (or in fact also use the site with time zones other than their own). My current idea to

SimpleDateFormat returns wrong date value during parse

允我心安 提交于 2019-12-11 11:33:21
问题 I m facing a problem:I want to get current time of GMT TimeZone in long. I m using the following code as given below: TimeZone timeZoneGmt = TimeZone.getTimeZone("GMT"); long gmtCurrentTime = getCurrentTimeInSpecificTimeZone(timeZoneGmt); public static long getCurrentTimeInSpecificTimeZone(TimeZone timeZone) { Calendar cal = Calendar.getInstance(); cal.setTimeZone(timeZone); long finalValue = 0; SimpleDateFormat sdf = new SimpleDateFormat( "MMM dd yyyy hh:mm:ss:SSSaaa"); sdf.setTimeZone

Parsing timezone from a string with offset using SimpleDateFormat

折月煮酒 提交于 2019-12-11 11:25:46
问题 Decided to ask this, as I couldn't find a similar example in StackOverflow. I want to parse a date string and its timezone using SimpleDateFormat. I (hope) I read the documentation carefully, and wrote this program that replicates the issue. import java.text.DateFormat; import java.util.Date; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Locale; public class SDF { private static final String FORMAT = "EEE, d MMM yyyy HH:mm:ss Z"; public static void main

Timezone parsing issue in Java

放肆的年华 提交于 2019-12-11 11:22:30
问题 How do i parse the following date string in a valid java date? I am having trouble parsing the timezone. "2013-10-10 10:43:44 GMT+5" I am using the following method for parsing the date. It works well when the timezone is like "GMT+05:00" but fails to parse the above string even if i use different combinations of z, Z, X public static Date convertStringWithTimezoneToDate(String dateString) { if (dateString == null) { return null; } SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM

addition of gmt times in php

故事扮演 提交于 2019-12-11 11:18:35
问题 i have a time zone in 2010-05-04T05:27:00.000Z format which indicates the GMT time and i want to add GMT 10+ in to it using php. i can do that thing using following code but how would i directly add 2010-05-04T05:27:00.000Z and GMT 10+ so that i can get a valid date and time. $offset=10*60*60; $dateFormat="d-m-Y H:i::m:s"; echo $timeNdate=gmdate($dateFormat, time()+$offset); 回答1: Maybe I'm missing the point but are you not really looking for DateTime::setTimezone? $timezone = new DateTimeZone

Calendar.HOUR_OF_DAY confusion

巧了我就是萌 提交于 2019-12-11 11:14:30
问题 I have this piece of code: Calendar cal = Calendar.getInstance(); cal.setTime(pDatum); cal.set(Calendar.HOUR_OF_DAY, Integer.valueOf(pHHMMTP.substring(0, 2))); cal.set(Calendar.MINUTE, Integer.valueOf(pHHMMTP.substring(2, 4))); cal.set(Calendar.MILLISECOND, 0); System.out.println(cal.getTime()); where pDatum is Sun Mar 27 00:00:00 CET 2016 , pHHMMTP is 02485 and pHHMMTP.substring(0, 2) is 02 . The output is: Sun Mar 27 03:48:00 CEST 2016 I would expect: Sun Mar 27 02:48:00 CEST 2016 First I

datetime.now in python different when running locally and on server

拈花ヽ惹草 提交于 2019-12-11 11:07:54
问题 I am using Heroku to run some python code. The code that i have written uses a predefined time like example: 16:00 and compares that with the current time and the calculates the difference like this: now = datetime.datetime.now() starttime = datetime.datetime.combine(datetime.date.today(), datetime.time(int(hour), int(minute))) dif = now - starttime Running this locally ofc uses the time in my system i guess and everything is correct. However when i post it on the server and run it there the

Converting from UTC into date format in R

纵然是瞬间 提交于 2019-12-11 11:06:19
问题 I have a UTC timestamp. I want to convert it into YYYY/MM/DD format in R . For example, 1318394558766 . I tried format command unsuccessfully. Any help is appreciated. Thanks! 回答1: You can use as.POSIXct or as.POSIXlt . However you have to know the origin date from which your number of milliseconds started. as.POSIXct(1318394558766/1000, origin='1970-01-01') > unlist(as.POSIXlt(1318394558766/1000, origin='1970-01-01')) sec min hour mday mon year wday yday isdst 38.766 42.000 21.000 11.000 9