I want to convert Unix timestamp (long value) to local tried to covert it. but its not showing local time (UTC +05.30).   here local time is 29-12-2018 01:38:09 PM  but Its showing 29-12-2018 05:51:09 AM  My code is as below. please suggest what i am missing?  var lastRecieved = DateTimeOffset.FromUnixTimeMilliseconds(1546062669090).DateTime.ToLocalTime(); string Timetest = lastRecieved.ToString("dd-MM-yyyy hh:mm:ss tt"); Console.WriteLine("Value in datetime format : " + Timetest);
33272
There is this example code, but then it starts talking about millisecond / nanosecond problems.  The same question is on MSDN, .  This is what I've got so far:  public Double CreatedEpoch {   get   {     DateTime epoch = new DateTime(1970, 1, 1, 0, 0, 0, 0).ToLocalTime();     TimeSpan span = (this.Created.ToLocalTime() - epoch);     return span.TotalSeconds;   }   set   {     DateTime epoch = new DateTime(1970, 1, 1, 0, 0, 0, 0).ToLocalTime();     this.Created = epoch.AddSeconds(value);   } }
83796
I have a file containing this:  1415602803,LOGIN SUCCESS,AUTH,user2,192.168.203.63,10.146.124.73,59996,22 1415602807,LOGIN SUCCESS,AUTH,user1,172.24.31.10,172.32.1.1,48191,22 1415602811,LOGIN FAILED,AUTH,root,172.24.166.153,10.146.124.73,52506,22 1415602815,LOGIN FAILED,AUTH,user3,192.168.123.55,10.146.32.99,55750,22   I want to convert the timestamp to a date in this format:  2014-11-10 02:00:03,LOGIN SUCCESS,AUTH,user2,192.168.203.63,10.146.124.73,59996,22 2014-11-10 02:00:07,LOGIN SUCCESS,AUTH,user1,172.24.31.10,172.32.1.1,48191,22 2014-11-10 02:00:11,LOGIN FAILED,AUTH,root,172.24.166.153,10.146.124.73,52506,22 2014-11-10 02:00:15,LOGIN FAILED,AUTH,user3,192.168.123.55,10.146.32.99,55750,22   How can I do that?  I know this works: perl -pe 's/(\d+)/localtime($1)/e' (from ) but the output format is Mon Nov 10 02:00:03 2014.  I know this command can convert timestamps into my desired output: date -d@1415602803 +"%F %H:%M:%S", but I couldn't make it work with awk using system("cmd") because of all the quotations and whatnot.
99429
Is there a fairly easy way to convert a datetime object into an RFC 1123 (HTTP/1.1) date/time string, i.e. a string with the format  Sun, 06 Nov 1994 08:49:37 GMT   Using strftime does not work, since the strings are locale-dependant. Do I have to build the string by hand?
49490
I have a tab delimited file where each record has a timestamp field in 12-hour format:     mm/dd/yyyy hh:mm:ss [AM|PM].   I need to quickly convert these fields to 24-hour time:     mm/dd/yyyy HH:mm:ss.   What would be the best way to do this? I'm running on a Windows platform, but I have access to sed, awk, perl, python, and tcl in addition to the usual Windows tools.
13684
I want to convert a string like this:  '10/15/2008 10:06:32 PM'   into the equivalent DATETIME value in Sql Server.  In Oracle, I would say this:  TO_DATE('10/15/2008 10:06:32 PM','MM/DD/YYYY HH:MI:SS AM')    implies that I must parse the string into one of the , and then convert using one of those codes.  That seems ludicrous for such a mundane operation.  Is there an easier way?
47935
I need to convert lat/long that is expressed as degrees, minutes, and seconds in the data into decimal degrees. For example, in the data, they are listed as N335042.06 in the Latitude column, and W86031.04 in the Longitude column. I have done this problem before where I created a script which converted DMS to DD, and vice-versa, so I guess I could use bits from that. But the problem I'm having is how to ignore (for lack of a better word) the 'N' and 'W' in the data? Can I skip them? And DMS are listed all together without any symbols or spaces.  Can I use len(), range(), split() to specify what part to read from the value? For example, can do the following?  N335042.06 where, 33 = degrees 50 = minutes 42.06 = seconds ...?  I came across  ESRI article, but it's in VB. Will probably use it as a reference but some of the terminology/syntax is different from Python.  Final code that works!   # Pre-logic def latDD(x):   D = int(x[1:3])   M = int(x[3:5])   S = float(x[5:])   DD = D + float(M)/60 + float(S)/3600   return DD  # Expression latDD(!Latitude!)
35028
I want the server to always serve dates in UTC in the HTML, and have JavaScript on the client site convert it to the user's local timezone.  Bonus if I can output in the user's locale date format.
30685
I have a Timestamp value that comes from my application. The user can be in any given local TimeZone.  Since this date is used for a WebService that assumes the time given is always in GMT, I have a need to convert the user's parameter from say (EST) to (GMT). Here's the kicker: The user is oblivious to his TZ. He enters the creation date that he wants to send to the WS, so what I need is:  User enters: 5/1/2008 6:12 PM (EST)  The parameter to the WS needs to be: 5/1/2008 6:12 PM (GMT)  I know TimeStamps are always supposed to be in GMT by default, but when sending the parameter, even though I created my Calendar from the TS (which is supposed to be in GMT), the hours are always off unless the user is in GMT. What am I missing?  Timestamp issuedDate = (Timestamp) getACPValue(inputs_, "issuedDate"); Calendar issueDate = convertTimestampToJavaCalendar(issuedDate); ... private static java.util.Calendar convertTimestampToJavaCalendar(Timestamp ts_) {   java.util.Calendar cal = java.util.Calendar.getInstance(       GMT_TIMEZONE, EN_US_LOCALE);   cal.setTimeInMillis(ts_.getTime());   return cal; }   With the previous Code, this is what I get as a result (Short Format for easy reading):  [May 1, 2008 11:12 PM]
18574
I'm trying to convert a date string into an age.  The string is like: "Mon, 17 Nov 2008 01:45:32 +0200" and I need to work out how many days old it is.  I have sucessfully converted the date using:  &gt;&gt;&gt; time.strptime("Mon, 17 Nov 2008 01:45:32 +0200","%a, %d %b %Y %H:%M:%S +0200") (2008, 11, 17, 1, 45, 32, 0, 322, -1)   For some reason %z gives me an error for the +0200 but it doesn't matter that much.  I can get the current time using:  &gt;&gt;&gt; time.localtime() (2009, 2, 3, 19, 55, 32, 1, 34, 0)   but how can I subtract one from the other without going though each item in the list and doing it manually?
24173
What is the best way to convert seconds into (Hour:Minutes:Seconds:Milliseconds) time?  Let's say I have 80 seconds, are there any specialized classes/techniques in .NET that would allow me to convert those 80 seconds into (00h:00m:00s:00ms) format like to DateTime or something?
82168
I was answering this  question and found strange result:   select * from  pg_timezone_names where name = 'Europe/Berlin' ;      name      | abbrev | utc_offset | is_dst  ---------------+--------+------------+--------  Europe/Berlin | CET    | 01:00:00   | f   and next query  select id,    timestampwithtimezone,    timestampwithtimezone at time zone 'Europe/Berlin' as berlin,    timestampwithtimezone at time zone 'CET' as cet  from data ;  id  | timestampwithtimezone  |       berlin        |         cet           -----+------------------------+---------------------+---------------------  205 | 2012-10-28 01:30:00+02 | 2012-10-28 01:30:00 | 2012-10-28 00:30:00  204 | 2012-10-28 02:00:00+02 | 2012-10-28 02:00:00 | 2012-10-28 01:00:00  203 | 2012-10-28 02:30:00+02 | 2012-10-28 02:30:00 | 2012-10-28 01:30:00  202 | 2012-10-28 02:59:59+02 | 2012-10-28 02:59:59 | 2012-10-28 01:59:59  106 | 2012-10-28 02:00:00+01 | 2012-10-28 02:00:00 | 2012-10-28 02:00:00   I'm using PostgreSQL 9.1.2 and ubuntu 12.04. Just checked that on 8.2.11 result is the same.  According to  it doesn't matter if I use name or abbreviation.  Is this a bug? Am I doing something wrong? Can someone explain this result?    EDIT For the comment that CET is not Europe/Berlin.  I'm just selecting values from pg_timezone_names.  select * from  pg_timezone_names  where abbrev ='CEST';  name | abbrev | utc_offset | is_dst  ------+--------+------------+--------   and  select * from  pg_timezone_names  where abbrev ='CET';         name         | abbrev | utc_offset | is_dst  ---------------------+--------+------------+--------  Africa/Tunis        | CET    | 01:00:00   | f  Africa/Algiers      | CET    | 01:00:00   | f  Africa/Ceuta        | CET    | 01:00:00   | f  CET                 | CET    | 01:00:00   | f  Atlantic/Jan_Mayen  | CET    | 01:00:00   | f  Arctic/Longyearbyen | CET    | 01:00:00   | f  Poland              | CET    | 01:00:00   | f  .....   During winter Europe/Berlin is +01. During summer it is +02.  EDIT2 In 2012-10-28 timezone has change from summer time to winter time at 2:00. This two records have the same value in Europe/Berlin:  204 | 2012-10-28 02:00:00+02 | 2012-10-28 02:00:00 | 2012-10-28 01:00:00 106 | 2012-10-28 02:00:00+01 | 2012-10-28 02:00:00 | 2012-10-28 02:00:00   This suggest that if I use one of abbreviations (CET or CEST) for big data range (summer time and winter time) result will be wrong for some of records. Will be good if I use 'Europe/Berlin'.  I changed the system time to '2012-01-17' and pg_timezone_names has changed also.  select * from  pg_timezone_names  where name ='Europe/Berlin';      name      | abbrev | utc_offset | is_dst  ---------------+--------+------------+--------  Europe/Berlin | CEST   | 02:00:00   | t
56522
Ever since I started using Linux in dualboot with Windows I noticed that when I rebooted the machine, the time on the other OS was wrong, e.g. it was 12:00 on Linux, then I rebooted and on Windows it was 18:00, and when I checked the BIOS, the RTC was set to 18:00. Since my timezone is -06:00 CST I assume Linux just sets the RTC’s time to UTC and re-calculates the time based on the timezone, whereas Windows just sets the RTC to the local time. Both use the same NTP server to sync the time.  The question is, which one is doing the right thing? On which one should I set the timezone setting to UTC in order to have the right time on both?
13230
I would like to think that some of the software I'm writing today will be used in 30 years. But I am also aware that a lot of it is based upon the UNIX tradition of exposing time as the number of seconds since 1970.  #include &lt;stdio.h&gt; #include &lt;time.h&gt; #include &lt;limits.h&gt;  void print(time_t rt) {     struct tm * t = gmtime(&amp;rt);     puts(asctime(t)); }  int main() {     print(0);     print(time(0));     print(LONG_MAX);     print(LONG_MAX+1); }   Execution results in:   Thu Jan  1 00:00:00 1970 Sat Aug 30 18:37:08 2008 Tue Jan 19 03:14:07 2038 Fri Dec 13 20:45:52 1901           The functions ctime(), gmtime(), and localtime() all take as an argument a time value representing the time in seconds since the Epoch (00:00:00 UTC, January 1, 1970; see time(3) ).      I wonder if there is anything proactive to do in this area as a programmer, or are we to trust that all software systems (aka Operating Systems) will some how be magically upgraded in the future?  Update It would seem that indeed 64-bit systems are safe from this:  import java.util.*;  class TimeTest {     public static void main(String[] args) {         print(0);         print(System.currentTimeMillis());         print(Long.MAX_VALUE);         print(Long.MAX_VALUE + 1);     }      static void print(long l) {         System.out.println(new Date(l));     } }    Wed Dec 31 16:00:00 PST 1969 Sat Aug 30 12:02:40 PDT 2008 Sat Aug 16 23:12:55 PST 292278994 Sun Dec 02 08:47:04 PST 292269055   But what about the year 292278994?
40410
Something similar to Unix's timestamp, that is a single number that represents the current time and date. Either as a number or a string.
119405
Does anyone know how to convert string time formats in ArcMap v10.2 from 12-hour to 24-hour using a simple query in the Field Calculator? i.e. NO Python, NO editing in Excel, NO changing my Windows PC settings, etc...  This is a successful calculation I used (which I found on a discontinued forum) to convert my dates from MM/DD/YYYY to YYYY/MM/DD:  year([DateFld]) &amp; "/" &amp; Month([DateFld]) &amp; "/" &amp; Day([DateFld])  Perhaps there is some sort of modification that I could make to the above calculation that would change my times to 24-hour?  I've searched for an answer everywhere and played around with it without any luck, but I would like for the times to be in h:mm:ss format.  Forgot to mention that this is a regular shapefile, not part of a GDB.
419
I need to parse  strings like "2008-09-03T20:56:35.450686Z" into Python's datetime type.  I have found  in the Python standard library, but it is not very convenient.  What is the best way to do this?
91838
Timestamp in the  is going out of it's boundary.        AFAIK, the suggested edits timestamp was near to it's type (i.e. asked, proposed) like this:        Checked on Chrome (27.0.1453.110 m), Firefox (21.0) on Windows XP  The issue is in other Stack Exchange sites as well. E.g. Have a look at  on Physics.SE. Also in   Can we fix this?