utc

How to convert a date to UTC properly and then convert it back?

与世无争的帅哥 提交于 2019-12-03 11:55:21
I'm struggling with converting DateTime to UTC, the concept and all, something I'm not understanding correctly. When I get a date time string, say "7/10/2013", I simply do Convert.ToDateTime("7/10/2013").ToUniversalTime(); This will record it as "7/10/2013 4:00:00 AM " in the database. Server is located at U.S East Coast (-5). Of course, during July 2013, DST is still being observed, so offset during that time is -4, such the extra 4 hours 4:00:00 AM " recorded as UTC. As I'm writing this post, it's Feb 2014 and DST is not in effect, so offset right now is -5. In my application, that's the

Creating a DateTime object with a specific UTC DateTime in PowerShell

痞子三分冷 提交于 2019-12-03 11:38:29
问题 I'm trying to create a DateTime object with a specific UTC timestamp in PowerShell. What's the simplest way to do this? I tried: Get-Date -Format (Get-Culture).DateTimeFormat.UniversalSortableDateTimePattern -Date "1970-01-01 00:00:00Z" but I get this output: 1969-12-31 19:00:00Z It's a few hours off. Where's my lapse in understanding? 回答1: The DateTime object itself is being created with the proper UTC time. But when PowerShell prints it out it converts it to my local culture and time zone,

Storing a leap second in SQL Server 2008

和自甴很熟 提交于 2019-12-03 11:21:14
This weekend is an extra long one as there will be an extra second inserted after 23:59:59 on June 30th. We have a system that logs a lot of data around the clock and one of the business rules is that no two records can be logged as having occurred at the same time, to within one second. We're using UTC datetimes along with the new datetimeoffset data type, but as far as I can tell they won't let you have more than 60 seconds in a minute. Certainly, this throws an error: select datediff(ss, getdate(), '30-jun-2012 23:59:60') But according to the UTC gods this will be a real time. Events can

Rails:How to create a time column with timezone on postgres

丶灬走出姿态 提交于 2019-12-03 11:20:46
I have a rails application which works on postgres db. I have a model called UserTimings where there are two fields from_time and to_time. t.time "from_time" t.time "to_time" I expected that the time will be stored in complete UTC format with timezone information. After a little while, I realized that the database has this kind SQL query to create the table. from_time time without time zone, to_time time without time zone, I do not want this. I want to store with time zone . I want the +0530 thingy in the UTC time which I'm not getting althought the rails application has been configured to

Using Joda-Time to get UTC offset for a given date and timezone

北城余情 提交于 2019-12-03 10:37:20
I have dates in the format 20Jan2013, 08Aug2012 etc, with their own specific timezones. So for example, 20Jan2013 might have a timezone ID of Australia/Melbourne, and 08Aug2012 might have an ID of Europe/London. What I want to do is, based on these timezones and the dates, calculate the UTC offset for that timezone on the given date. I've come up with this so far: DateTimeFormatter dtf = DateTimeFormat.forPattern("ZZ"); DateTimeFormatter dtf1 = DateTimeFormat.forPattern("ddMMMYYYY"); DateTimeZone zone = DateTimeZone.forID("Australia/Melbourne"); DateTime thisDate = dtf1.parseDateTime(

Chaincode for Developers Cli error terminal 3

匿名 (未验证) 提交于 2019-12-03 09:06:55
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I am trying to deploy chaincode using the chain code for developers tutorial " http://hyperledger-fabric.readthedocs.io/en/latest/chaincode4ade.html ". I was able to complete the steps till Terminal 2 but get an Error in the command "docker exec -it cli bash" for Terminal 3. Output for Terminal 1: []Received message REGISTER from shim peer | 2017-08-22 23:29:26.025 UTC [chaincode] HandleMessage -> DEBU 1a9 []Fabric side Handling ChaincodeMessage of type: REGISTER in state created peer | 2017-08-22 23:29:26.025 UTC [chaincode]

hyperledger fabric first_network example create channel got BAD_REQUEST

匿名 (未验证) 提交于 2019-12-03 09:02:45
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I have been following tutorial on hyper ledger website: https://hyperledger-fabric.readthedocs.io/en/release/build_network.html#behind-scenes . I was able to run ./byfn.sh -m generate ./byfn.sh -m up This setup run all the way through of showning the end. like: ===================== All GOOD, BYFN execution completed ===================== _____ _ _ ____ | ____| | \ | | | _ \ | _| | \| | | | | | | |___ | |\ | | |_| | |_____| |_| \_| |____/ ./byfn.sh -m down Then I begun to follow the tutorial further to execute each line manually. I have

Javascript New Date() / UTC - GMT cross browser

匿名 (未验证) 提交于 2019-12-03 08:46:08
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: The issue : Different formats for new Date() in IE 10 - IE 11. Javascript: IE 11 / Chrome : var m = new Date("2014-07-04T04:00:00"); console.log(m); // Fri Jul 04 2014 06:00:00 GMT+0200 (W. Europe Summer Time) IE 10: var m = new Date("2014-07-04T04:00:00"); console.log(m); // Fri Jul 4 04:00:00 UTC+0200 2014 Is possible to use one ring to rule them all? 回答1: You shouldn't pass a string to new Date , specifically for this reason. Instead, you should either give it the individual arguments: new Date(2014, 6, 4, 4, 0, 0); // remember months are

Convert UTC time to local time using Nodatime

匿名 (未验证) 提交于 2019-12-03 08:46:08
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I have been provided a time in this format "ddMMyyHHmmss". I know the time is in UTC format. I would like to use the NodaTime library to convert this to my local timezone but I can't seem to figure it out. My local timezone target is to be New Zealand. Here's what I have tried: var pattern = LocalDateTimePattern.CreateWithInvariantCulture("ddMMyyHHmmss"); var parseResult = pattern.Parse(utcDateTime); if (!parseResult.Success) { throw new InvalidDataException("Invalid time specified " + date + time); } var timeZone = DateTimeZoneProviders.Bcl

Groovy date format for UTC with milliseconds

匿名 (未验证) 提交于 2019-12-03 08:33:39
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I'm having trouble finding a good way of formatting a UTC-time stamp with this format: yyyyMMdd-HH:mm:ss.<three additional digits> I wasn't able to find any character that represents milliseconds/hundredths, I'm not even sure this is possible, to parse that format that is. Ideally I'd like to use the parseToStringDate that's part of the Date library. My plan b is to convert yyyyMMdd-HH:mm:ss to milliseconds and then add the three last digits to that number. 回答1: Use yyyyMMdd-HH:mm:ss.SSS This will get you milliseconds as well. Test Code: def