timezone

Converting date from database to a different timezone

泪湿孤枕 提交于 2019-12-24 03:51:13
问题 I have a website that allows people to post things. When they post, it gets inserted into the database and the database adds a timestamp. When I hosted the database on my local machine, the timestamps were in my time zone. My new hosting website has it set to GMT time. How can I make it display the time in my time zone? I've tried adding date_default_timezone_set('America/New_York'); to my views just under the tag, but that doesn't help. Any ideas? 回答1: // Set the time zone $dateTimeZone =

Optimize/Index Timezone Query

强颜欢笑 提交于 2019-12-24 03:37:08
问题 I'm wondering if anyone has any recommendations on how to optimize this query so it can use an index? We have reservations that are associated to properties in our database. Each property has a timezone set. What we want to query for is "all reservations that start on a given date (e.g. today)". The relevant query fragment is reservations.start_on::Date = COALESCE((current_timestamp at time zone properties.time_zone), current_timestamp)::Date The properties table is joined earlier in the

Rails datetime_select posting my current time in UTC

你说的曾经没有我的故事 提交于 2019-12-24 03:29:38
问题 I'm trying to compare what the user selects for a start date and end date to the current time to prevent the user from selecting a time in the past. It works except you have to pick a time, in my case, 4 hours ahead in order for it to pass the validation. View: datetime_select(:start_date, ampm: true) Controller: if self.start_date < DateTime.now || self.end_date < DateTime.now errors.add(:date, 'can not be in the past.') end self.start_date is returning my current time but in utc which is

Facebook Events and timezones, how to convert UTC datetime to what facebook expects?

隐身守侯 提交于 2019-12-24 03:00:13
问题 My application needs to create facebook events. Everything works fine, but I can't get the timezones correct. The start/end dates are all wrong. Facebook's Event API docs say this: Note: The start_time and end_time are the times that were input by the event creator, converted to UTC after assuming that they were in Pacific time (Daylight Savings or Standard, depending on the date of the event), then converted into Unix epoch time. (source) I can't figure out what that means. My web

How to get the data time pattern with time zone based on the locale?

痞子三分冷 提交于 2019-12-24 02:16:04
问题 The following code is what I already have: DateFormat f = DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT, Java_Locale); SimpleDateFormat sf = (SimpleDateFormat) f; String pattern = sf.toPattern(); With the above code, I am able to get the PROPER date/time pattern based on the locale. For example: "M/d/yy h:mm a" for US English, "yy-M-d ah:mm" for Chinese. However, this pattern does not have the time zone information. I hope to be able to add time zone into the pattern. For

Calendar TimeZone inDaylightTime returns incorrect answer for Israel

人走茶凉 提交于 2019-12-24 01:05:11
问题 Israel has recently changed its laws regarding DST such that when using the Calendar.getTimeZone().inDaylightTime(date) method, the response for the date range September 6th - October 27th is incorrect when deploying code to app engine. Interestingly when running on local dev server the range of dates that cause incorrect responses is different. Is there a short term workaround for this? What is the process for asking google to fix this? 回答1: The change you describe is captured in the IANA

Selenium scraping: changing timezone

隐身守侯 提交于 2019-12-24 01:04:38
问题 The website I run my headless (PhantomJS) browser through Selenium has different timezone so I get the wrong dates for many entries. Thus my scraped results show the wrong dates/times (i'm in EST, looks like website default is GMT). I'm scraping from this website. You can get an idea of how i'm scraping dates through a previous question on SO here. Note however i'm not currently scraping the times of games so i'd prefer not to incorporate this in a solution. The same question is asked here

Python - converting UTC millisecond timestamp to local time

泄露秘密 提交于 2019-12-24 00:47:23
问题 I have a Unix epoch timestamp in milliseconds and need to get date string in local time. This is my code: date = datetime.utcfromtimestamp(timestamp / 1000).strftime('%d-%m-%Y') hour = datetime.utcfromtimestamp(timestamp / 1000).strftime('%H') month = datetime.utcfromtimestamp(timestamp / 1000).strftime('%m') monthName = calendar.month_name[int(month)] weekDay = calendar.day_name[(datetime.strptime(date, '%d-%m-%Y')).weekday()] The original timestamp and the resulting date, hour and all other

Dealing with DateTime and Timezones with Java / Postgres

孤街醉人 提交于 2019-12-23 23:25:08
问题 I am creating an application that let's a user create an event with a date. For example - Birthday, 25.09.2018. (The user is asked only for the date). I want to store these event objects in my Postgres DB. At the end of that date (it means at 23:59:59 on 25.09.2018) I want my application to set a flag on the event expired = true . My initial idea is to run a Scheduler every full hour, check the records for events and if the current server time is greater that the stored event time, set the

php.ini disable daylight saving

柔情痞子 提交于 2019-12-23 21:16:37
问题 Our country stopped daylight saving. Now the time is 20:16 But on PHP the time is 21:16. Is there any way to disable daylight saving? My code is: echo date('Y-m-d H:i:s'); 回答1: The 2016 change for Azerbaijan is correctly reflected in the time zone database for the Asia/Baku time zone as of release 2016c. PHP gets its time zone information from the timezonedb PECL package. The 2016c tz data, inclusive of the Azerbaijan change, is in timezonedb version 2016.3. An embedded copy of this is