timezone

how do I make my site timezone aware?

白昼怎懂夜的黑 提交于 2019-12-11 13:57:21
问题 I have an app that uses import datetime datetime.datetime.now() default=datetime.now auto_now=True auto_now_add=True I'm changing the above codes to the below. from django.utils import timezone timezone.now() # instead of datetime.datetime.now() default=timezone.now # instead of datetime.now auto_now # override save() or pre_save() .. ok don't need this change in recent django. auto_now_add # override post_save() to set time when `created`.. don't need this change either Am I missing

How can I get the ctime and/or mtime of a file in Python including timezone?

拥有回忆 提交于 2019-12-11 13:35:49
问题 Based on this related question and answer I asked, it has become obvious that datetime.fromtimestamp(os.path.getctime()) in Python 3.4 doesn't return a timezone-aware datetime object, However, based on some investigation, I've also discovered that OS X 10.9 on an HFS+ filesystem (for example) does seem to maintain the timezones along with ctimes (unless gls is inferring the timezone from my local timezone and daylight-savings time): $ gls -l --full-time -c -rw------- 1 myuser staff 538 2015

SimpleDateFormat ignoring DST offset in Android

淺唱寂寞╮ 提交于 2019-12-11 13:23:30
问题 In Central Europe, the current time zone (as of 3rd October) is: CEST / UTC+2 But when I create an instance of SimpleDateFormat in Android now ... dateTimeFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ"); ... it returns CET / UTC+1 as the time zone. So it's ignoring the DST offset which must still be there at the moment. Why is this? Furthermore, when using the (now deprecated) method getTimezoneOffset() of Date instances, it returns inconsistent results: (new Date())

How to store date in database based on different calendars?

萝らか妹 提交于 2019-12-11 13:14:37
问题 I'm gonna change current local date to new local date and time. As something I know, This is the code: For example: date_default_timezone_set("Asia/Calcutta"); date_default_timezone_get(); // Show current date & time or using third party to change date, something like this: header('Content-Type: text/html; charset=UTF-8'); require_once dirname(__FILE__) . '/jdatetime.class.php'; $local = jDateTime::date("l j F Y", strtotime($date), true, true, 'Asia/Tehran'); break; These ways only can set

How to change a time zone in a data frame?

本秂侑毒 提交于 2019-12-11 12:57:39
问题 I am loading a csv into a dataframe using str <- readLines("Messages.csv", n=-1, skipNul=TRUE) matches <- str_match(str, pattern = "\\s*([0-9]{2}/[0-9]{2}/[0-9]{4}),\\s*([0-9]{2}:[0-9]{2}:[0-9]{2}),\\s*(Me|Them),\\s*(\\+[0-9]{11,12}),\\s*((?s).*)") df <- data.frame(matches[, -1], stringsAsFactors=F) colnames(df) <- c("date","time","sender","phone number","msg") # Format the date and create a row with the number of characters of the messages df <- df %>% mutate(posix.date=parse_date_time

php - adjusting for timezones

梦想的初衷 提交于 2019-12-11 12:35:46
问题 Alright so I have this code which makes a list of dates: $dates = array(); for($i = 1; $i < 10; $i++) { $datetime = mktime(12, 0, 0, date('n'), date('j') + $i, date('Y')); if(date('N', $datetime) != 6 && date('N', $datetime) != 7) { $dates[date('l, F jS', $datetime)] = date('l, F jS', $datetime); } } The dates are tomorrow and on as long as they are not Saturday or Sunday. Now the problem is "tomorrow" is being changed at like 8:00 PM EST. To explain, say it's Wednesday. The first option in

convert gmt to local timezone in pandas

倾然丶 夕夏残阳落幕 提交于 2019-12-11 12:08:52
问题 I have a gmt timestamp and I need to convert it into a local timezone ( taking into account daylight saving ). do you know how to do that in pandas? thanks! 回答1: tz_localize is a possible candidate. http://pandas.pydata.org/pandas-docs/version/0.17.1/generated/pandas.Series.tz_localize.html 来源: https://stackoverflow.com/questions/34584500/convert-gmt-to-local-timezone-in-pandas

MySQL ISO 8601 Date with Timezone offset instead of Z value

拜拜、爱过 提交于 2019-12-11 12:07:48
问题 I need to SELECT a ISO 8601 Date. DATE_FORMAT(date, '%Y-%m-%dT%TZ') This produces something like 2013-11-13T15:47:530Z But I need it with the offset instead of Z value: 2013-11-13T15:47:53+02:00 How can I do this with plain MySQL ? 回答1: You need to store the timezone as an extra column in DB. I do not know any DB that stores datetime with timezone/offset. Or store the date as string in ISO 8601 format with offset.. Edit: I stand somewhat corrected, with some newer databases it is possible!

Timezone inconsistencies on converting XMLGregorianCalendar to LocalDateTime

别等时光非礼了梦想. 提交于 2019-12-11 11:57:47
问题 So I have an XML Soap response with date / time fields, which are represented as follows: <BusStopTime> <BusStopId>1023</BusStopId> <Order>1</Order> <PassingTime>1899-12-30T07:20:00</PassingTime> </BusStopTime> I'm not interested in the date (as this is some legacy representation which I don't have control over) but the time. The field is transformed to XMLGregorianCalendar by the WS tooling and I'm aiming to do the conversion. var date = DatatypeFactory.newInstance() .newXMLGregorianCalendar

date.getTimezoneOffset() is not returning an expected value

随声附和 提交于 2019-12-11 11:57:27
问题 My browser is running in the Eastern Standard Timezone, when call I call date.getTimezoneOffset() I expect -300 to be returned but instead I get 300 var date = new Date(); date.getTimezoneOffset(); // returns 300 回答1: From the Mozilla docs (or devdocs.io): Return value The time-zone offset is the difference, in minutes, between UTC and local time. Note that this means that the offset is positive if the local timezone is behind UTC and negative if it is ahead. For example, if your time zone is