utc

Is return value of GetTimeZoneInformation also valid for dynamic DST zones?

空扰寡人 提交于 2019-12-07 20:34:03
问题 Following function which I have written in Delphi (however, my question is not specific to Delphi) does output the current UTC unix timestamp: function CurrentUnixTimeUTC: int64; var tzi: TTimeZoneInformation; begin // Get the current unix timestamp in local time. Result := DateTimeToUnix(Now); // First, add the DST specific bias case GetTimeZoneInformation(tzi) of TIME_ZONE_ID_INVALID: RaiseLastOSError; TIME_ZONE_ID_UNKNOWN: ; // Unknown what to do. We simply don't apply any bias. TIME_ZONE

Rolling file on utc date rather than server date

爱⌒轻易说出口 提交于 2019-12-07 14:23:12
问题 This is my log4net.xml file <log4net> <appender name="RollingFile" type="log4net.Appender.RollingFileAppender"> <file value="C:\MVC2-" > </file> <appendToFile value="true" /> <rollingStyle value="Date" /> <datePattern value="yyyy'-'MM'-'dd'.log'" /> <dateTimeStrategy type="log4net.Appender.RollingFileAppender+UniversalDateTime" /> <lockingModel type="log4net.Appender.FileAppender+MinimalLock" /> <staticLogFileName value="false" /> <layout type="log4net.Layout.PatternLayout">

Convert Time to UTC vbScript

早过忘川 提交于 2019-12-07 02:32:22
问题 I have the following function which does fine at converting current time to UTC time. Function toUtc(byVal dDate) Dim oShell : Set oShell = CreateObject("WScript.Shell") toUtc = dateadd("n", oShell.RegRead("HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\TimeZoneInformation\ActiveTimeBias"), cDate(dDate)) End Function However, I am thinking that this does not adequately handle conversion of future or historical dates to UTC, since the function would need to know the offset of the server's

Number of seconds since the beginning of the day UTC timezone

点点圈 提交于 2019-12-06 20:58:05
问题 How do I find "number of seconds since the beginning of the day UTC timezone" in Python? I looked at the docs and didn't understand how to get this using datetime.timedelta . 回答1: Here's one way to do it. from datetime import datetime, time utcnow = datetime.utcnow() midnight_utc = datetime.combine(utcnow.date(), time(0)) delta = utcnow - midnight_utc print delta.seconds # <-- careful EDIT As suggested, if you want microsecond precision, or potentially crossing a 24-hour period (i.e. delta

ASP.NET: Get milliseconds since 1/1/1970

北城余情 提交于 2019-12-06 19:41:56
问题 I have an ASP.NET, VB.NET Date, and I'm trying to get the number of milliseconds since January 1st, 1970. I tried looking for a method in MSDN, but I couldn't find anything. Does anyone know how to do this? 回答1: You can subtract any two DateTime instances and get TimeSpan and TotalMilliseconds would give you total milliseconds. Sample below. DateTime dt1970 = new DateTime(1970, 1, 1); DateTime current = DateTime.Now;//DateTime.UtcNow for unix timestamp TimeSpan span = current - dt1970;

Java, Hibernate, MySQL - store UTC date-time

女生的网名这么多〃 提交于 2019-12-06 15:52:04
问题 I saw here on SO a few related questions (like this one and of course, this one)... Essentially, what I want is to store date-time as UTC, and let application user choose the time zone he wants to display date-time in. Since it seems that date-time fields are affected by the underlying JDBC driver, I wonder if this is an acceptable way to go about storing UTC date-time: Set both MySQL and Application server machine to UTC time zone (no need to separate) Both MySQL and JVM should pick up

Converting DateTime + TimeZone to UTC

大兔子大兔子 提交于 2019-12-06 13:36:11
How can I get universal time for a specified TimeZone, given a DateTime object? My application (a Timer) asks the user to specify a time and a timezone and I need to save the UTC based on the specified time+timezone values. For example, user A specifies DateTime: 07/06/2011 7:30 AM TimeZone: Eastern Standard Time (-5:00). User B specifies: DateTime: 07/06/2011 05:00 PM TimeZone: India Standard Time (+5:30). I believe the UTC for both the above DateTime values will be the same and both of the above timers will occur at the same time. The problem is how do I get the UTC to save in the database?

Parsing ISO8601 date/time with DateTime struct

痴心易碎 提交于 2019-12-06 12:07:29
问题 I am trying to parse an ISO8601 formatted date/time string with .NET's DateTime structure. In order for me to give a full underdstanding of the problem, I am going to perform tests using both .NET and JavaScript. I am currently in Britain (British Summer Time, which is UTC+01:00). My understanding of ISO8601 is that: When the string is suffixed with "Z", the time is expressed in UTC. When the string is suffixed with "+/-hh:mm", the time is expressed in Local time, where the "+/-hh:mm"

How to get UTC time with windows batch file

我只是一个虾纸丫 提交于 2019-12-06 11:04:24
问题 I have been trying to find a way of getting a windows batch file to display the current UTC time when run. So in other words get the current amount of milliseconds since it was initiated in 1970. Does anyone know how to do this. 回答1: Using WMI: for /f %%x in ('wmic path win32_utctime get /format:list ^| findstr "="') do set %%x This will set the variables Day , DayofWeek , Hour , Minute , Month , Quarter , Second , WeekInMonth and Year which you can use, then. You won't get a time with Unix

Django DateTime field to generate timestamp fields withOUT timezone

自闭症网瘾萝莉.ら 提交于 2019-12-06 08:41:41
问题 I am working on a Django application where I need all the postgres represented datetime fields to be saved in UTC (as they should). When I'm creating models with DateTime fields they database representation is generated as " timestamp with time zone ". Although I can manually alter the tables to remove the timezone from the fields, I was wondering if the DateTime model field has the ability to not do that - i.e., create " timestamp with out time zone " for some fields. Is that possible? Or do