utc

How do I convert local time to UTC?

喜夏-厌秋 提交于 2020-01-04 05:29:04
问题 I want to convert my local time (shown below) to UTC. Local time can belong to any timezone which a user belongs to. I just want to convert it to UTC format. Local Time : '2015-12-04 19:05:48' How do I achieve this requirement in JavaScript or AngularJS? Update My Original date/time string as like this "Mon March 28 2016 23:59:59 GMT -0600 (CENTRAL DAYLIGHT TIME)" and I have converted them to "2016-03-28 23:59:59 CDT" as requested date format. But again, I need to convert this interim output

ZonedDateTime to UTC with offset applied?

若如初见. 提交于 2020-01-01 10:07:56
问题 I am using Java 8 This is what my ZonedDateTime looks like 2013-07-10T02:52:49+12:00 I get this value as z1.format(DateTimeFormatter.ISO_OFFSET_DATE_TIME) where z1 is a ZonedDateTime . I wanted to convert this value as 2013-07-10T14:52:49 How can I do that? 回答1: Is this what you want? This converts your ZonedDateTime to a LocalDateTime with a given ZoneId by converting your ZonedDateTime to an Instant before. LocalDateTime localDateTime = LocalDateTime.ofInstant(z1.toInstant(), ZoneOffset.UTC

In VBA, How to convert a UTC UNIX timestamp to Local timezone Date in a simple way?

萝らか妹 提交于 2020-01-01 07:04:21
问题 As I know, we can use below to roughly convert a UNIX timestamp to a VB Date CDate([UNIX timestamp]/ 60 / 60 / 24) + "1/1/1970" However, the time zone and daylight information are not considered. Time zone is not a big deal. But I cannot get the daylight bias information for a specific UNIX timestamp. Though, daylight bias of Date 1/1 is obviously different from Date 6/1, however, for Date 3/12 or Date 11/5, the daylight bias calculation is very complex. I tried several APIs, like

How to I convert long (currentTimeInMillis) to UTC timestamp?

泄露秘密 提交于 2020-01-01 05:51:47
问题 My client is sending me Long which could be thought as scala> System.currentTimeMillis res3: Long = 1441056836609 scala> How do I convert that into UTC timeStamp? On Server, we are using Java 8 回答1: You can use the Instant class methods. import java.time.Instant; import java.time.ZoneOffset; Instant.ofEpochMilli(<yourmillis>).atOffset(ZoneOffset.UTC).toString(); Your example date would be "2015-08-31T21:33:56.609Z" . 回答2: Date dateFromTime = new Date(timeInMillis); That will get a Date object

Changing current user timezone based on server UTC offset and user UTC offset

江枫思渺然 提交于 2020-01-01 05:50:09
问题 im writing a twitter web service in php. When a user signs in, i receive this node: <utc_offset>-18000</utc_offset> I have to change the script's timezone so that it adapts to the user's real timezone. The only php function i have found for this is: date_default_timezone_set($timezone_identifier) but it won't let me use -18000 as a the $timezone_identifier parameter. So, how can i change the current user timezone based on two values: Server UTC offset and User UTC offset BTW, this is how i'm

C# convert UTC int to DateTime object

吃可爱长大的小学妹 提交于 2020-01-01 05:19:34
问题 I don't know why this is so complicated! I have a plugin that is passing in a long int UTC. I need to convert that number into a DateTime to query my database (SQL Server). I don't know why, but I can't find a workable answer from a basic google search. (For extra credit, I need to turn my returned DateTime back into a UTC at the end of the day.) This is embarrassing to have to ask such a basic question! :) 回答1: My guess is it's going to be either milliseconds or seconds since a particular

Rails:How to create a time column with timezone on postgres

时光毁灭记忆、已成空白 提交于 2020-01-01 04:25:09
问题 I have a rails application which works on postgres db. I have a model called UserTimings where there are two fields from_time and to_time. t.time "from_time" t.time "to_time" I expected that the time will be stored in complete UTC format with timezone information. After a little while, I realized that the database has this kind SQL query to create the table. from_time time without time zone, to_time time without time zone, I do not want this. I want to store with time zone . I want the +0530

Python datetime not including DST when using pytz timezone

杀马特。学长 韩版系。学妹 提交于 2020-01-01 04:17:24
问题 If I convert a UTC datetime to swedish format, summertime is included (CEST). However, while creating a datetime with sweden as the timezone, it gets CET instead of CEST. Why is this? >>> # Modified for readability >>> import pytz >>> import datetime >>> sweden = pytz.timezone('Europe/Stockholm') >>> >>> datetime.datetime(2010, 4, 20, 16, 20, tzinfo=pytz.utc).astimezone(sweden) datetime(2010, 4, 20, 18, 20, tzinfo=<... 'Europe/Stockholm' CEST+2:00:00 DST>) >>> >>> datetime.datetime(2010, 4,

Using Joda-Time to get UTC offset for a given date and timezone

会有一股神秘感。 提交于 2020-01-01 04:12:09
问题 I have dates in the format 20Jan2013, 08Aug2012 etc, with their own specific timezones. So for example, 20Jan2013 might have a timezone ID of Australia/Melbourne, and 08Aug2012 might have an ID of Europe/London. What I want to do is, based on these timezones and the dates, calculate the UTC offset for that timezone on the given date. I've come up with this so far: DateTimeFormatter dtf = DateTimeFormat.forPattern("ZZ"); DateTimeFormatter dtf1 = DateTimeFormat.forPattern("ddMMMYYYY");

How can I set a Calendar with UTC time?

不羁岁月 提交于 2019-12-31 17:52:55
问题 The posters here say that Date is always in UTC time. However, if I create a Date(), create a Calendar, and set the calendar time with the date, the time remains my local time (and I am not on UTC time. I've tested this by printing out the calendar's date in a loop, subtracting an hour per loop. It's 11pm on the 19th of May here, and it takes 24 loops before the date changes to the 18th of May. It's currently 1pm UTC, so if the calendar were set properly it would only take 14 loops. Date date