timezone

How do I get Greenwich Mean Time in PHP?

痴心易碎 提交于 2019-12-17 06:29:09
问题 I have a server which is set to EST, and all records in the database are set to EST. I would like to know how to set it to GMT. I want to offer a time zone option to my users. 回答1: No matter in which GMT time zone the server is, here is an extremely easy way to get time and date for any time zone. This is done with the time() and gmdate() functions. The gmdate() function normally gives us GMT time, but by doing a trick with the time() function we can get GMT+N or GMT-N, meaning we can get the

Timezones in SQL DATE vs java.sql.Date

我们两清 提交于 2019-12-17 06:27:11
问题 I'm getting a bit confused by the behaviour of the SQL DATE data type vs. that of java.sql.Date . Take the following statement, for example: select cast(? as date) -- in most databases select cast(? as date) from dual -- in Oracle Let's prepare and execute the statement with Java PreparedStatement stmt = connection.prepareStatement(sql); stmt.setDate(1, new java.sql.Date(0)); // GMT 1970-01-01 00:00:00 ResultSet rs = stmt.executeQuery(); rs.next(); // I live in Zurich, which is CET, not GMT.

How to use TimeZoneInfo to get local time during Daylight Saving Time?

亡梦爱人 提交于 2019-12-17 06:25:14
问题 I'm trying to use DateTimeOffset to convey a specific moment in time across any time zone. I can't figure out how to use TimeZoneInfo to deal with daylight saving time. var dt = DateTime.UtcNow; Console.WriteLine(dt.ToLocalTime()); var tz = TimeZoneInfo.FindSystemTimeZoneById("Central Standard Time"); var utcOffset = new DateTimeOffset(dt, TimeSpan.Zero); Console.WriteLine(utcOffset.ToOffset(tz.BaseUtcOffset)); This prints out: 6/2/2010 4:37:19 PM 6/2/2010 3:37:19 PM -06:00 I am in the

Mapping US zip code to time zone

别等时光非礼了梦想. 提交于 2019-12-17 05:41:28
问题 When users register with our app, we are able to infer their zip code when we validate them against a national database. What would be the best way to determine a good potential guess of their time zone from this zip code? We are trying to minimize the amount of data we explicitly have to ask them for. They will be able to manually set the time zone later if our best guess is wrong. I realize zip codes won't help with figuring out the time zone outside the US, but in that case we'd have to

Difference between UTC and GMT Standard Time in .NET

我是研究僧i 提交于 2019-12-17 05:00:37
问题 In .NET, the following statements return different values: Response.Write( TimeZoneInfo.ConvertTime( DateTime.Parse("2010-07-01 5:30:00.000"), TimeZoneInfo.FindSystemTimeZoneById("Pacific Standard Time"), TimeZoneInfo.FindSystemTimeZoneById("GMT Standard Time")) ); // displays 7/1/2010 1:30:00 PM ..and this... Response.Write( TimeZoneInfo.ConvertTime( DateTime.Parse("2010-07-01 5:30:00.000"), TimeZoneInfo.FindSystemTimeZoneById("Pacific Standard Time"), TimeZoneInfo.FindSystemTimeZoneById(

Difference between UTC and GMT Standard Time in .NET

安稳与你 提交于 2019-12-17 05:00:10
问题 In .NET, the following statements return different values: Response.Write( TimeZoneInfo.ConvertTime( DateTime.Parse("2010-07-01 5:30:00.000"), TimeZoneInfo.FindSystemTimeZoneById("Pacific Standard Time"), TimeZoneInfo.FindSystemTimeZoneById("GMT Standard Time")) ); // displays 7/1/2010 1:30:00 PM ..and this... Response.Write( TimeZoneInfo.ConvertTime( DateTime.Parse("2010-07-01 5:30:00.000"), TimeZoneInfo.FindSystemTimeZoneById("Pacific Standard Time"), TimeZoneInfo.FindSystemTimeZoneById(

How to convert time to the time zone of the iPhone device?

家住魔仙堡 提交于 2019-12-17 03:48:12
问题 I have a time in EST timezone, it is done using the NOW() function on the mysql server. Because my server is located in EST, the time stored is in EST. When I retrieve it from my app on the iPhone, I need to display it in the correct time zone of the user. How do I do that? 回答1: I think it depends on what you mean by EST - if you mean East Coast US, then in general, that is 5 hours behind UTC (but not accounting for daylight saving), which should give you 04:00 EST. Try to avoid using

How to ignore user's time zone and force Date() use specific time zone

こ雲淡風輕ζ 提交于 2019-12-17 03:24:59
问题 In an JS app, I receive timestamp (eq. 1270544790922 ) from server (Ajax). Basing on that timestamp I create Date object using: var _date = new Date(); _date.setTime(1270544790922); Now, _date decoded timestamp in current user locale time zone. I don't want that. I would like _ date to convert this timestamp to current time in city of Helsinki in Europe (disregarding current time zone of the user). How can I do that? 回答1: A Date object's underlying value is actually in UTC. To prove this,

How to get client's timezone? [duplicate]

十年热恋 提交于 2019-12-17 02:31:36
问题 This question already has answers here : How to detect user's timezone? (6 answers) Closed 4 years ago . I'm writting an application using Zend_Framework (so the solution can rely on it). How to get client's timezone? For example, if someone in Moscow, Russia, I want to get 3*60*60 (because there is UTC+3). If he is in UK, I want zero. If he uses UTC-3:30 (Canada?), I want -3.5*60*60. (it's not a question about a format - I'm ok with getting 'Europe/Moscow' or 'UTC-3' for St. Petersburg,

Get time of specific timezone [duplicate]

こ雲淡風輕ζ 提交于 2019-12-17 02:10:34
问题 This question already has answers here : Convert date to another timezone in JavaScript (22 answers) Closed 3 years ago . I am using a JavaScript Date class & trying to get the current date using getDate() method. But obviously it is loading system date & time. I am running the code from India but I want to get the date & time of UK using the same method. How can I do that ? 回答1: If you know the UTC offset then you can pass it and get the time using the following function: function calcTime