timezone

How to change the php server time zone? [closed]

不想你离开。 提交于 2020-01-06 03:06:44
问题 It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center. Closed 7 years ago . We can use any simple code to display the system time only but I need some code to find the server(PHP) time zone and how to change the server time zone? 回答1: date_default_timezone_set('America/Los_Angeles');

Parsing string to date with timezone in national format

南笙酒味 提交于 2020-01-06 03:05:54
问题 I try to parse string (russian locale) "01 августа 2014, пятница. 20:00 МСК" to java.util.Date. I try this code: String dateString = "01 августа 2014, пятница. 20:00 МСК" Locale rusLocale = new Locale.Builder().setLanguage("ru").setScript("Cyrl").build(); String pattern = "dd MMMM yyyy, EEEE. HH:mm z" Date date = SimpleDateFormat(pattern, rusLocale).parse(dateString) With month and weekday this code work fine, but when I try to parse string with timezone name МСК I get java.text

Rails - time zone conversion

倾然丶 夕夏残阳落幕 提交于 2020-01-06 02:56:05
问题 I'm trying to convert a datetime with an external timezone field into UTC. Can someone explain to me why this doesn't work? time_str = '2016-03-01 00:00' zone_str = 'Pacific Time (US & Canada)' Time.use_zone(zone_str) { Time.parse(time_str).in_time_zone('UTC') } What I'm expecting: '2016-03-01 08:00' What I'm getting: '2016-03-01 06:00' Basically, it's ignoring my use_zone call and just using my local time zone, which is Central. What should I be doing instead? -- edit -- Note that I am NOT

How to get a zulu timezone representation of the current date

时光怂恿深爱的人放手 提交于 2020-01-06 02:27:08
问题 I would like to get the current date in ISO 8601 (rfc3339), Zulu format: 2015-10-13T10:26:43Z How can I do this in Javascript? 回答1: You can use toISOString() var isoDate = new Date().toISOString(); console.log(isoDate); Hope it helps, 来源: https://stackoverflow.com/questions/33100656/how-to-get-a-zulu-timezone-representation-of-the-current-date

Server strtotime incorrect

时光毁灭记忆、已成空白 提交于 2020-01-06 02:14:37
问题 Both strtotime and mktime are outputting an incorrect timestamp and it's driving me mad. If I add the following strtotime('2012-10-09'); I get 1349701200 Which is actually Mon, 08 Oct 2012 13:00:00 GMT I'm using my localhost, running MAMP. I'm assuming it's a server timezone issue, or something, but I don't understand why, or how to fix it. Any help? 回答1: strtotime uses default timezone to interpret the string. If you want different timezone you could specify it explicitly or change it for

How do I get the current time in a different TimeZone in Java?

半城伤御伤魂 提交于 2020-01-05 15:44:14
问题 OK - I feel pretty dumb asking such a basic question, but hey. I'm trying to get the current time in a different timezone in a Java webapp. I've tried the following obvious solution: in my servlet, Calendar localCalendar = Calendar.getInstance(myBean.getTimeZone()); then I pass the calendar object through to a JSP as a request attribute 'localCalendar': It is now: [${requestScope.localCalendar.time}] in TimeZone ${requestScope.localCalendar.timeZone.ID} but my output seems to ignore the

UTC String to Date and UTC Time Calculations

|▌冷眼眸甩不掉的悲伤 提交于 2020-01-05 09:14:53
问题 I have a string, that I know will be reference to an UTC timestamp @"2016-01-20T17:00:00" now when converting it to an actual NSDate it returns this when printed out: NSLog("%@", [TimeHelper stringToDateInUtc:@"2016-01-20T17:00:00"]); -> 2016-01-20 18:00:00 +0000 Same thing with a UTC date: NSLog(@"Time in UTC Now: %@", [TimeHelper getNowUtcAsDate]); I also have this method for getting the current time in UTC and convert the string to UTC: + (NSDate*) stringToDateInUtc:(NSString*)str {

Android how to get device's time not timezone time

寵の児 提交于 2020-01-05 08:29:55
问题 My case is: user set timezone to UTC+5 , for example, and then turn off time and timezone sync. When he goes to UTC+4 timezone, he just set the time back to an hour, without touching timezone. So the Calendar.getInstance() and System.currentTimeMillis() return the time for UTC+5 , for example, 14:00, but the device shows 13:00. How can I get the device time(13:00) or difference between device time and current timezone time? 回答1: All that I could find, kept here in this post. Summary : it is

PHP: Get Time for Current Region

£可爱£侵袭症+ 提交于 2020-01-05 07:26:29
问题 I have a timezone of the user(he chooses it from a list) I have a time in UTC(not current time) So I need something like GetTimeForRegion(time, timezone) for PHP. Is there such functions or libraries or services? 回答1: you can use DateTime::setTimezone(). If your UTC date is an UNIX timestamp, you can use some code like this : $date = new DateTime(); $date->setTimezone(new DateTimeZone('UTC')); $date->setTimestamp(1297869844); $date->setTimezone(new DateTimeZone('Europe/Paris')); echo $date-

How do you define postgres functions in Rails and what is their scope and lifetime?

六月ゝ 毕业季﹏ 提交于 2020-01-05 07:05:36
问题 I know nothing about Postgres functions however the need to use them has come up a couple of times recently (this may be indicative that I'm approaching the problem incorrectly but regardless...) I would like to define a Postgres function like this which I will then access via queries in my Rails app: CREATE FUNCTION date_in_time_zone(time_zone) RETURNS date AS 'SELECT DATE(NOW() AT TIME ZONE time_zone);' LANGUAGE SQL; (from this question). Question part 1: How do I define this function? I