timezone

How to get different timezones' current time in PHP?

时光毁灭记忆、已成空白 提交于 2019-12-20 06:08:24
问题 Unfortunately I'm not using PHP 5. On the documentation of the date function it has a timezone section which lets you specify the difference from the GMT tome. How can you use that to get the current/local time in a specified timezone, and does it with with daylights savings? 回答1: You can convert times to different timezones by using the PEAR Date package http://pear.php.net/package/Date Examples here http://pear.php.net/manual/en/package.datetime.date.examples.php 来源: https://stackoverflow

Create a local date from a UTC date string in Moment.js

和自甴很熟 提交于 2019-12-20 04:58:07
问题 Given a UTC date string (formatted: YYYYMMDDHHmmss) I'd like to create a date with the local timezone using Moment.js. I have tried the following: var utcDateStr = '20140101120000'; var localDate = moment.utc(utcDateStr, 'YYYYMMDDHHmmss'); //actual: true //desired: false console.log(localDate._isUTC) //actual: "Wed Jan 01 2014 12:00:00 GMT+0000" //desired: "Wed Jan 01 2014 07:00:00 GMT-0500" console.log(localDate.toString()) How do I create a date that is formatted in the local time zone by

TimeZoneInfo.ConvertTime from PST to UTC to AEST - off by one hour

若如初见. 提交于 2019-12-20 04:28:16
问题 I convert a string that represents a time in Pacific Time Zone that I am using to create a DateTime object: var pacificDateTime = new DateTime(2016, 11, 16, 15, 0, 0) // 11/16/2016 3:00:00 PM Using that, I create a DateTimeOffset because ultimately it becomes a bit easier to work with. var pacificTimeZoneInfo = TimeZoneInfo.FindSystemTimeZoneById("Pacific Standard Time"); var dateTimeNoKind = new DateTime(pacificDateTime.Ticks, DateTimeKind.Unspecified) var DateTimeOffsetValue = TimeZoneInfo

Why doesn't C# detect that 1970/1/1 was under BST?

非 Y 不嫁゛ 提交于 2019-12-20 04:18:56
问题 I'm working with a 3rd party API that returns Time of Day values as DateTime values filling in Jan 1, 1970 as the date part. So for 5AM, it will return something like 1969-12-31T21:03:00.000-08:00 The problem is that, when if the user was on London time, C# fails to apply BST adjustment for 1970-01-01. For example, 1970-01-01 5AM in UTC should be 1970-01-01 6AM in London. See conversion But, C# doesn't seem to apply this conversion: var utcTime = new DateTime(1970, 1, 1, 5, 0, 0, DateTimeKind

Convert unix timestamp between different timezones and different DST in Java

半腔热情 提交于 2019-12-20 04:13:08
问题 PROBLEM SOLVED External device was computing and sending non-standard 2 hours shifted timestamp, which hugely confused me and started this thread. TIMESTAMP BY ITSELF IS NOT AFFECTED BY TIMEZONES , timezones apply only when converting in/from human readable forms. I have timestamp (seconds from unix epoch) in UTC timezone - no DST (daylight saving time). I want timestamp (seconds from unix epoch) in "Europe/Prague" timezone, that uses DST. I used to think that unix timestamp is unbound by

Date Conversion In java Web Application

爱⌒轻易说出口 提交于 2019-12-20 04:10:23
问题 String date1 = "13/03/2014 16:56:46 AEDT"; SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss z"); sdf.setTimeZone(TimeZone.getTimeZone("GMT+12")); java.util.Date convertedDate = (java.util.Date) sdf.parse(date1); SimpleDateFormat outFormatter = new SimpleDateFormat("EE MMM dd yyyy HH:mm:ss z"); outFormatter.setTimeZone(TimeZone.getTimeZone("GMT+12")); String output = outFormatter.format(convertedDate); System.out.println("Date in NZ Timezone : " + output); I am trying to

How can i know time in a specific country if i am in a differenet country?

泄露秘密 提交于 2019-12-20 03:54:31
问题 I am trying to do it this way 1. Get my time current time and time zone. 2. I know time zone of that specific country from Google. 3. Calculate difference in time zones. 4. Subtract this difference from current time. This will give me time in other country. I am stuck at step 3 and 4. I get current time like this Date d = new Date(); CharSequence s = DateFormat.format("hh:mm:ss", d.getTime()); and time zone like this Calendar calendar = Calendar.getInstance(TimeZone.getTimeZone("GMT"), Locale

PHP > Set Default Timezone

流过昼夜 提交于 2019-12-20 03:52:43
问题 We want to set the timezone up as a variable in PHP to account for different timezones / daylight savings. Our code works perfectly when hard coded: date_default_timezone_set('Australia/Brisbane'); But when we add a variable it dies. I am not sure why. $setzone = "Australia/Brisbane"; date_default_timezone_set('".$setzone."'); 回答1: if you will add quote then variable behaving as string for instance $setzone = "Australia/Brisbane"; echo '".$setzone."'; Output : ".$string." //output as string

Force a particular Timezone across an application

守給你的承諾、 提交于 2019-12-20 03:52:26
问题 A tricky situation here. Our application runs in a system that is set with a particular TimeZone (let's say Asia time). However a client request that his application to be run using Europe timezone. Since our data are not stored in UTC, is there anyway we can set the locale in the application so that all dates displayed will be using Europe TimeZone? I understand that we can set the Culture info at the Web.Config but i'm not sure whether that can help set the TimeZone as well. BTW our

Transform timestamp to local time for a given timezone during 'COPY .. TO ..'

十年热恋 提交于 2019-12-20 03:51:29
问题 I have a log table in a PostgreSQL database with an event column of type timestamp without time zone . Now I have a bash script, which creates a CSV file from the log database: ... psql .. -c "COPY (SELECT event, ... FROM logtable order by event desc) TO STDOUT WITH CSV" logdb > log.csv ... This is executed on the cloud server on which the DB is hosted and therefore, the timestamp strings in log.csv are in local time of the timezone of the server. However, I like to have the timestamp strings