timezone

Get the time zone GMT offset in C

纵饮孤独 提交于 2019-12-17 16:06:38
问题 I'm using the standard mktime function to turn a struct tm into an epoch time value. The tm fields are populated locally, and I need to get the epoch time as GMT. tm has a gmtoff field to allow you to set the local GMT offset in seconds for just this purpose. But I can't figure out how to get that information. Surely there must be a standard function somewhere that will return the offset? How does localtime do it? 回答1: Just do the following: #define _GNU_SOURCE /* for tm_gmtoff and tm_zone */

PHP - strtotime, specify timezone

瘦欲@ 提交于 2019-12-17 15:38:27
问题 I have a date string, say ' 2008-09-11 '. I want to get a timestamp out of this, but I need to specify a timezone dynamically (rather then PHP default). So to recap, I have two strings: $dateStr = '2008-09-11'; $timezone = 'Americas/New_York'; How do I get the timestamp for this? EDIT: The time of day will be the midnight of that day.... $dateStr = '2008-09-11 00:00:00'; 回答1: $date = new DateTime($dateStr, new DateTimeZone($timezone)); $timestamp = $date->format('U'); 回答2: The accepted answer

Before writing a Java Date to an SQL TIMESTAMP column, does JDBC translate the date from the JVM time zone to the database session time zone?

早过忘川 提交于 2019-12-17 15:28:45
问题 Before writing a Java Date to an SQL TIMESTAMP column, does JDBC translate the date from the Java virtual machine time zone to that of the database session? For example, suppose the Java virtual machine time zone is UTC and the database session time zone is UTC-5. If a Java program attempts to store 2000-01-01 00:00:00 by passing it to PreparedStatement#setTimestamp(int, Timestamp), according to the JDBC standard, will the database store TIMESTAMP '2000-01-01 00:00:00' or TIMESTAMP '1999-12

Set a default time zone for f:convertDateTime

谁说我不能喝 提交于 2019-12-17 15:24:41
问题 I use JSF1.2 and I have a little problem with time zones. Calendar respects my timezone and save the correct time in the Database. When I show it using a h:outputtext with a f:convertDateTime it shows the wrong date (I think with default time zone). I can do something like: <h:outputText value="#{atividade.atividade.dataCriacao.time}"> <f:convertDateTime pattern="#{msg.formatoDataCalendario2}" timeZone="America/Sao_Paulo" /> </h:outputText> formatoDataCalendario2 = dd/MM/yyyy, HH:mm in

TimeZones in Java

孤者浪人 提交于 2019-12-17 10:59:07
问题 I am allowing users on my web app to schedule events based on time zones of their choice. I want to present a good list of time zones to the end user and then convert it easily to java.util.TimeZone object at the server end. String[] TimeZone.getAvailableIds() is something I could use, but the issue is that it prints about 585 time zone ids. What is the best way to present to the user a brief list of time zones (like a Windows box would for time zone settings) and easily convert to TimeZone

Rails: How to parse date-time string into a specific time zone

巧了我就是萌 提交于 2019-12-17 10:53:09
问题 I'm using Rails 3.2 and ruby 1.9.3 on Debian. I have an app that collects a date, time, and timezone in the form of strings via an HTML form. Something like this: start_date: "04-15-2010", start_time: "10:00:00", timezone: "Central Time (US & Canada)" What I'd like to do is parse these 3 elements into a single date that is saved into my database as UTC, which in this case would add 7 hours to the start time, once it's in the UTC time zone. So the stored time would be 17:00 once it's in the DB

Location based Timezone Retrieval

和自甴很熟 提交于 2019-12-17 10:52:21
问题 Given: LDAP stores location of users. How do I drive their timezones using their location? Any pointers are accepted, Java language preferred. Thanks in advance. 回答1: This depends on information the "location" contains? You'd somehow need to map the location to a timezone name, preferably the Olson style timezone names, because they are more detailed and easier to map, as they are locations themselves. If it's an approximate addres (like country and city or so) then several geolocation

How to convert time correctly across timezones?

冷暖自知 提交于 2019-12-17 10:34:42
问题 Let's say user in CA, US picks up a date, time and timezone: Worldwide beer marathon starts on 8/15/2013 10:00 am, UTC-08:00 Another user, in Central Europe opens the page where this date and time is displayed. He doesn't want to do time calculations (had few beers already). He just wants to see this date and time: 8/15/2013 19:00 Given the browser receives the date and time information, as entered by user in California: Is there a way, in javascript , without external web services , to do a

Timezone with rails 3

家住魔仙堡 提交于 2019-12-17 10:17:20
问题 I have pretty common issue but for some reason i have tried all the suggestions on the web and none seem to work. I have set the Timezone in config to 'EST' config.time_zone = 'Eastern Time (US & Canada)' But when the time is shown on the the screen, it continues to show the UTC time that is stored in the DB. I tried the debugger and here is the output (rdb:1) Time.zone #<ActiveSupport::TimeZone:0x1061f4760 @utc_offset=nil, @current_period=nil, @name="Eastern Time (US & Canada)", @tzinfo=#

Convert UTC to “local” time in Go

半世苍凉 提交于 2019-12-17 09:47:08
问题 How can I convert UTC time to local time ? I've created a map with the UTC difference for all the countries I need the local time. Then I add that difference as duration to the current time (UTC) and print the result hoping that's the local time of that specific country. For some reasons the result is wrong. For example with Hungary there is one hour difference. Any idea why I'm getting incorrect results? package main import "fmt" import "time" func main() { m := make(map[string]string) m[