timezone

Laravel + Carbon + Timezone

青春壹個敷衍的年華 提交于 2020-07-21 05:21:25
问题 I have configured the timezone in config/app.php to Europe/Lisbon . If I do a return date_default_timezone_get(); , It returns Europe/Lisbon like I want. So far so good! When I do Carbon::now() it returns for example 16 hour while the current time is 17h. Can someone explain why the daylight saving aren't considered? I'm using Laravel 7.16, PHP 7.4 Regards EDIT 1: Code image + Times | https://imgur.com/pfh6uij EDIT 2: always done php artisan optimize:clear to clear all caches when I change

How to translate between windows and IANA timezones in java

↘锁芯ラ 提交于 2020-07-18 04:37:52
问题 I need to translate between IANA timezone & windows timezone & vice-versa. There is another question reported: How to translate between Windows and IANA time zones? It specifies that Noda time library can be used in .Net Do we have any library to be used in Java? Or any other utility to be used in java? 回答1: This may be what you need, but I don't know if it will work for all your use cases: for (String tzId : TimeZone.getAvailableIDs()) { TimeZone tz = TimeZone.getTimeZone(tzId); if (tz

converting timezone to 3 characters ZoneId

人走茶凉 提交于 2020-07-16 07:01:18
问题 I want to convert TimeZone such as "America/Chicago" to "CST". I can make use of SHORT_IDS map of ZoneID class. However, there are limited number of timezones configured in that map. What if I want to get "Asia/Hong_Kong" to "HKT", then this map will not get me correct answer. Is there any library which I can make use of, if something is not provided by Java. I am avoiding creating mapping of these timezones in my application. Any advice here would be greatly appreciated. 回答1: Use TimeZone

get client's GMT offset in javascript

て烟熏妆下的殇ゞ 提交于 2020-07-15 08:53:46
问题 how can I get the GMT offset in javascript of the client? new Date().getTimezoneOffset(); returns the difference from UTC. Is there a way I can calculate the GMT offset from that? By GMT offset, I mean as in -5 for eastern standard time. 回答1: new Date().getTimezoneOffset(); returns the difference from UTC. Is there a way I can calculate the GMT offset from that? The timezone offset is the difference from GMT in minutes (see ECMA-262 §15.9.5.26). The sign is the reverse of ISO 8601, but it's

Script inserted today's date into spreadsheet is wrong

我只是一个虾纸丫 提交于 2020-07-10 09:56:26
问题 I'm working on a bounded to spreadsheet script for a client, the spreadsheet is owned by them. Among other many things the script should insert today's date into a Google Sheets spreadsheet cell. The problem is that the inserted date is wrong and always the same. I made a copy of the spreadsheet to try to debug my code / find out what setting is wrong but I'm unable to reproduce the problem, like looking at and playing with the spreadsheet and script project timezone settings. This is the

How do I get local time in another timezone in dot net core

别说谁变了你拦得住时间么 提交于 2020-07-10 08:14:08
问题 I'm working on a problem in which I need to get the current date and time in another timezone. I don't know what timezone my code will be run on, and it needs to work on both windows and linux machines. I have not found any way of doing this. Any ideas? (P.S: I specifically need to find what time it is in Sweden including daylight savings from any arbitrary timezone the code might be running in). 回答1: The IANA time zone ID for Sweden is "Europe/Stockholm" (for use on Linux, OSX, and other non

How do I get local time in another timezone in dot net core

折月煮酒 提交于 2020-07-10 08:12:41
问题 I'm working on a problem in which I need to get the current date and time in another timezone. I don't know what timezone my code will be run on, and it needs to work on both windows and linux machines. I have not found any way of doing this. Any ideas? (P.S: I specifically need to find what time it is in Sweden including daylight savings from any arbitrary timezone the code might be running in). 回答1: The IANA time zone ID for Sweden is "Europe/Stockholm" (for use on Linux, OSX, and other non

Unexpected date when converting POSIXct date-time to Date - can timezone fix it?

徘徊边缘 提交于 2020-07-09 11:52:31
问题 When I try to coerce a POSIXct date-time to a Date using as.Date , it seems to return wrong date. I suspect it has got something to do with the time zone. I tried the tz argument in as.Date , but it didn't give the expected date. # POSIXct returns day of month 24 data$Time[3] # [1] "2020-03-24 00:02:00 IST" class(data$Time[3]) # [1] "POSIXct" "POSIXt" # coerce to Date, returns 23 as.Date(data$Time[3]) # [1] "2020-03-23" # try the time zone argument, without luck as.Date(data$Time[3], tz =

How to keep UTC time in logging while changing the TIME_ZONE settings?

淺唱寂寞╮ 提交于 2020-07-08 11:06:06
问题 I set the time zone in the settings.py file of my django project: TIME_ZONE = 'US/Eastern' and now my logs contain US/Eastern times. I would like to keep an UTC time in my logs. Is that possible? 回答1: Django uses Python's logging facilities, so there shouldn't be anything Django-specific here. According to the logging documentation, setting logging.Formatter.converter = time.gmtime should make all logs output in UTC. Alternatively, you can make your own Formatter class to use UTC: class

How to keep UTC time in logging while changing the TIME_ZONE settings?

余生颓废 提交于 2020-07-08 11:05:06
问题 I set the time zone in the settings.py file of my django project: TIME_ZONE = 'US/Eastern' and now my logs contain US/Eastern times. I would like to keep an UTC time in my logs. Is that possible? 回答1: Django uses Python's logging facilities, so there shouldn't be anything Django-specific here. According to the logging documentation, setting logging.Formatter.converter = time.gmtime should make all logs output in UTC. Alternatively, you can make your own Formatter class to use UTC: class