utc

How to get an UTC date string in Python? [duplicate]

為{幸葍}努か 提交于 2019-12-31 17:51:14
问题 This question already has answers here : How to get UTC time in Python? (7 answers) How to print a date in a regular format? (22 answers) Closed last year . I am trying to get utc date string as "YYYYMMDD" For now I do the following, nowTime = time.gmtime(); nowDate = date(nowTime.tm_year, nowTime.tm_mon, nowTime.tm_mday) print nowDate.strftime('%Y%m%d') I used to do: datetime.date.today().strftime() but this gives me date string in local TZ How can I get an UTC date string? 回答1: from

Human readable UTC datetime

北城以北 提交于 2019-12-31 05:34:12
问题 I have date time in this format: 2017-04-01T17:35:00.000Z how can I format it with Php and transform it in a nicer look to read? I tried with: date_format('2017-04-01T17:35:00.000Z',"F j, Y, g:i a"); and it returns me a false boolean 回答1: PHP Code demo <?php $timestamp= strtotime("2017-04-01T17:35:00.000Z"); echo date("F j, Y, g:i a",$timestamp); Output: April 1, 2017, 5:35 pm 来源: https://stackoverflow.com/questions/43309621/human-readable-utc-datetime

C# UTC DateTime query in WCF/.NET

心已入冬 提交于 2019-12-31 01:44:06
问题 This is a very simple, (hopefully) question. I am new to working with DateTime conversion in .NET. I have a WCF service which has a DateTime property - call it BookingDate. Someone passes that to my WCF service in the format: <a:BookingDate>2012-03-26T17:03:00-04:00</a:BookingDate> The server that it is sitting on is set to a timezone of UTC (Lisbon, London, Dublin). When I store the corresponding value in the database, it sets the value to be: 2012-03-26 22:03 I assumed, I think incorrectly

java display Windows UTC time

半城伤御伤魂 提交于 2019-12-30 14:09:14
问题 Windows stores FileTime internally as the number of 100-nanoseconds since 1.1.1601 UTC as a 64bit field, is it possible to get java to print out the current number? Just looking for an example as I can't find a way to do it. I would like to print the number out? Any help woudl be greatful! Thanks. 回答1: Approximately long diff1601to1970 = 315532800 * 1000000000; // <-- diff in nanoseconds(1/1/1601 to 1/1/1970) long currentFrom1970 = System.currentTimeMillis() * 1000000; long currentFrom1601 =

convert to UTC without changing php timezone settings

僤鯓⒐⒋嵵緔 提交于 2019-12-30 06:56:25
问题 How can I convert the time zone of a date string in php without changing the default time zone. I want to convert it locally to display only. The php time zone settting should not be modified. EDIT: My source time is a UTC string, I want to convert it to a different format, retaining the time zone as UTC, but php is converting it to local timezone. The code I used was: date('Y-m-d H:i::s',strtotime($time_str)); How do I retain timezone? 回答1: $src_tz = new DateTimeZone('America/Chicago');

convert to UTC without changing php timezone settings

一笑奈何 提交于 2019-12-30 06:56:15
问题 How can I convert the time zone of a date string in php without changing the default time zone. I want to convert it locally to display only. The php time zone settting should not be modified. EDIT: My source time is a UTC string, I want to convert it to a different format, retaining the time zone as UTC, but php is converting it to local timezone. The code I used was: date('Y-m-d H:i::s',strtotime($time_str)); How do I retain timezone? 回答1: $src_tz = new DateTimeZone('America/Chicago');

Updating time offset with moment().utcOffset()

时光怂恿深爱的人放手 提交于 2019-12-30 03:50:11
问题 I'm facing some issue trying to use moment.js for dealing with time offsets. I collect in an hidden input the local user time offset: <script type="text/javascript"> $(document).ready(function () { $('input#timeoffset').val(moment().utcOffset()); }); </script> The offset gets correctly stored (in my case its value is -240). Later on the server side (which runs in utc time) I try to update some db stored utcDate doing something like: var userDate = moment(utcDate).utcOffset(offset) My issue is

How to convert a week number to a date in Javascript

谁说我不能喝 提交于 2019-12-29 06:18:38
问题 I had tried to find some work done but I haven't had luck. Any ideas? Examples: Week, 1, 2001 => 2001-01-01 Week, 26, 2007 => 2007-06-01 回答1: As Kevin's code does not implement ISO 8601 properly (first day of the first week of year must be a Monday), I've corrected it and ended up with (also check it on jsfiddle): function firstDayOfWeek(week, year) { if (year==null) { year = (new Date()).getFullYear(); } var date = firstWeekOfYear(year), weekTime = weeksToMilliseconds(week), targetTime =

java Timezone setDefault effects

浪尽此生 提交于 2019-12-29 06:17:04
问题 following How to store date/time and timestamps in UTC time zone with JPA and Hibernate I want to set my application default time zone to UTC. My app runs on tomcat on a linux server along side some other apps. The server has other tomcat instances that run even more apps. Will Timezone.setDefault(tz) affect the other apps on the same tomcat instance? Will it affect other apps on other tomcat instances? Is it possible to set the timezone only for the app? I loosely remember something about

Rehydrating fluent nhibernate configured DateTime as Kind Utc rather than Unspecified

寵の児 提交于 2019-12-29 03:37:08
问题 Is there a way in fluent nhibernate to map a DateTime to rehydrate my entity with DateTime.Kind set to Utc rather than unspecified? I'm currently persisting a DateTime that is Utc, but the Kind coming back is always Unspecified, throwing off my time. 回答1: This isn't specific to fluent, but is fundamental to the NHibernate mapping. We use an interceptor to specify the Kind. It is similar to the approach in this blog post which lists a couple alternatives. There is also a proposed patch (NH