utc

Back and forth UTC dates in lua

*爱你&永不变心* 提交于 2019-12-02 00:44:09
问题 I'm having problems converting a lua date to a timestamp and then obtaining back the original date from it. It does work for non UTC dates, but not with UTC. Currently my example code is: local dt1 = os.date( "*t" ); print( dt1.hour ); local dt2 = os.date( "*t", os.time( dt1 ) ); print( dt2.hour ); print( "-=-=-" ); local dt1 = os.date( "!*t" ); print( dt1.hour ); local dt2 = os.date( "!*t", os.time( dt1 ) ); print( dt2.hour ); local dt2 = os.date( "*t", os.time( dt1 ) ); print( dt2.hour );

C# UTC DateTime query in WCF/.NET

送分小仙女□ 提交于 2019-12-01 22:40:24
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 that the .NET framework (as part of the WCF serialize/deserialize process) would pop this into a .Net

What is this about adjustment rules when converting DateTime to UTC?

馋奶兔 提交于 2019-12-01 21:43:35
问题 In the MSDN page for TimeZoneInfo.ConvertTimeToUtc(), there is this info box: If the current computer's local time zone includes multiple adjustment rules, this overload of the ConvertTimeToUtc method can return results that differ from the TimeZone.ToUniversalTime and DateTime.ToUniversalTime methods. TimeZone.ToUniversalTime always applies the current adjustment rule to time zone conversion, whether or not dateTime lies within its date range. And when executing on .NET Framework 3.5,

How to create a Date object, using UTC, at a specific time in the past?

泪湿孤枕 提交于 2019-12-01 21:26:47
Is it possible to create a java.util.Date object that is guaranteed to be UTC and at a specific time in the past, like an hour ago or a day ago, and is this a good idea? I have reviewed the Stack Overflow question get date as of 4 hours ago and its answers. But I want to avoid having to add more dependencies, like jodaTime , and the accepted answer uses System.currentTimeMillis() which would be the local timezone, would it not? Ole V.V. As discussed vividly in the comments, the recommendation is to use the java.time package. The easy solution: Instant fourHoursAgo = Instant.now().minus

Back and forth UTC dates in lua

早过忘川 提交于 2019-12-01 20:53:22
I'm having problems converting a lua date to a timestamp and then obtaining back the original date from it. It does work for non UTC dates, but not with UTC. Currently my example code is: local dt1 = os.date( "*t" ); print( dt1.hour ); local dt2 = os.date( "*t", os.time( dt1 ) ); print( dt2.hour ); print( "-=-=-" ); local dt1 = os.date( "!*t" ); print( dt1.hour ); local dt2 = os.date( "!*t", os.time( dt1 ) ); print( dt2.hour ); local dt2 = os.date( "*t", os.time( dt1 ) ); print( dt2.hour ); Which yields the output: 12 12 -=-=- 10 9 11 So, in the second part, after obtaining the timestamp using

How to Convert to UTC

流过昼夜 提交于 2019-12-01 20:36:20
问题 I'm getting dates & times from various sources (e.g. file's date/time from FTP server, email's date/tiem received, etc.) and need to store them all as UTC (so they all have a common reference). How do I do this? What pieces of information do I need in order to properly do the conversion. This is for a PHP web application. So, I can get my server's time zone. I'm not sure what to do next. Here are some sample inputs: Mon, 28 Jun 2010 12:39:52 +1200 2010-06-25 15:33:00 回答1: For the first case

ActiveRecord is not aware of timezones?

↘锁芯ラ 提交于 2019-12-01 19:18:05
I have one question regarding to time zone I have done the following yet, my activerecord is not still matching with my timezone when I do following query def stock_by_date(date) UserStock.where("date(created_at) = ? and user_id = ? ", date , current_user.id) end I did the following in side my application.rb config.active_record.default_timezone = :utc config.active_record.time_zone_aware_attributes = true config.beginning_of_week = :sunday config.active_record.time_zone_aware_types = [:datetime, :time] I added timezone field to my sign up method, and it shows the current day of timezone

How to Convert to UTC

我是研究僧i 提交于 2019-12-01 19:01:01
I'm getting dates & times from various sources (e.g. file's date/time from FTP server, email's date/tiem received, etc.) and need to store them all as UTC (so they all have a common reference). How do I do this? What pieces of information do I need in order to properly do the conversion. This is for a PHP web application. So, I can get my server's time zone. I'm not sure what to do next. Here are some sample inputs: Mon, 28 Jun 2010 12:39:52 +1200 2010-06-25 15:33:00 For the first case the offset is there so it should be trivial, the second example however will be considered as UTC (or any

What is the difference between DateTime.ToUniversalTime and TimeZoneInfo.ConvertTimeToUtc

只愿长相守 提交于 2019-12-01 17:41:27
问题 I'm just starting to think properly about rolling out a webapp that will need to do things to users at the start of their day, say 6am. Also at the end of their days. Everywhere I've been reading about people saying a lot just to use .ToUniversalTime to store the time in UTC, but when I tried this (as I suspected) it didn't work, and it just moved the time about by an hour (I'm in the UK, so I thought this was to do with some offset from GMT to UTC, although that doesn't make sense to me, as

Javascript: Convert a UTC Date() object to the local timezone

我是研究僧i 提交于 2019-12-01 17:36:39
I have a Date() object that contains a UTC date, which I need converted to the users local timezone. Does anybody know how I could do this? :-) I usually create a new Date object and use the Date.setUTC* functions to copy the date information. I'm pretty sure it is done for you automatically. >>> d = new Date('Fri, 10 Jun 2011 19:49:23 UTC'); Sat Jun 11 2011 07:49:23 GMT+1200 (New Zealand Standard Time) >>> d.getHours(); 7 Mike Gledhill This is an old thread, but just in case anyone else stumbles across this issue, here's how I got around this problem. UTC dates from ASP.Net In my example, I