Questions tagged [epoch]

Unix time, or POSIX time, is a system for describing points in time, defined as the number of seconds elapsed since midnight Coordinated Universal Time (UTC) of January 1, 1970, not counting leap seconds. This tag is *not* for epochs as used in neural networks/machine learning.

Unix time, or POSIX time, is a system for describing points in time, defined as the number of seconds elapsed since midnight Coordinated Universal Time (UTC) of January 1, 1970, not counting leap seconds.

It is used widely, not only in Unix-like operating systems, but also in many other computing systems and file formats.

It is neither a linear representation of time nor a true representation of UTC (though it is frequently mistaken for both), as it cannot unambiguously represent UTC leap seconds (e.g. December 31, 1998 23:59:60), although otherwise the times it represents are UTC.

Unix time may be checked on some Unix systems by typing date +%s on the command line.

1440 questions
969
votes
23 answers

How can I convert a Unix timestamp to DateTime and vice versa?

There is this example code, but then it starts talking about millisecond / nanosecond problems. The same question is on MSDN, Seconds since the Unix epoch in C#. This is what I've got so far: public Double CreatedEpoch { get { DateTime epoch…
Mark Ingram
  • 71,849
  • 51
  • 176
  • 230
519
votes
5 answers

Why is 1/1/1970 the "epoch time"?

Why is 1 January 1970 00:00:00 considered the epoch time?
rahul
  • 184,426
  • 49
  • 232
  • 263
483
votes
14 answers

How do you convert epoch time in C#?

How do you convert Unix epoch time into real time in C#? (Epoch beginning 1/1/1970)
hsatterwhite
  • 7,160
  • 5
  • 26
  • 29
473
votes
13 answers

How can I convert a datetime object to milliseconds since epoch (unix time) in Python?

I have a Python datetime object that I want to convert to unix time, or seconds/milliseconds since the 1970 epoch. How do I do this?
SuperString
  • 21,593
  • 37
  • 91
  • 122
397
votes
17 answers

Convert UTC Epoch to local date

I have been fighting with this for a bit now. I’m trying to convert epoch to a date object. The epoch is sent to me in UTC. Whenever you pass new Date() an epoch, it assumes it’s local epoch. I tried creating a UTC object, then using setTime() to…
Shane Reustle
  • 8,633
  • 8
  • 40
  • 51
344
votes
5 answers

In Python, how do you convert seconds since epoch to a `datetime` object?

The time module can be initialized using seconds since epoch: >>> import time >>> t1=time.gmtime(1284286794) >>> t1 time.struct_time(tm_year=2010, tm_mon=9, tm_mday=12, tm_hour=10, tm_min=19, tm_sec=54, tm_wday=6, tm_yday=255,…
Adam Matan
  • 128,757
  • 147
  • 397
  • 562
298
votes
14 answers

Android Get Current timestamp?

I want to get the current timestamp like that : 1320917972 int time = (int) (System.currentTimeMillis()); Timestamp tsTemp = new Timestamp(time); String ts = tsTemp.toString();
Rjaibi Mejdi
  • 6,820
  • 3
  • 21
  • 26
298
votes
8 answers

Convert python datetime to epoch with strftime

I have a time in UTC from which I want the number of seconds since epoch. I am using strftime to convert it to the number of seconds. Taking 1st April 2012 as an example. >>>datetime.datetime(2012,04,01,0,0).strftime('%s') '1333234800' 1st of April…
Noel
  • 3,749
  • 3
  • 22
  • 21
181
votes
7 answers

How to get a timestamp in Dart?

I've been learning Dart, but I don't know how to generate a timestamp. I have tried this: void main() { print((new Date()).millisecondsSinceEpoch); } Thanks to the IDE I was able to get this far, but I'm getting a confusing error: Exception: No…
user1781056
154
votes
1 answer

How do I get epoch time in C#?

Possible Duplicate: How do you convert epoch time in C#? I'm trying to figure out how to get the epoch time in C#. Similar to the timestamps given on this website: http://www.epochconverter.com/ Does DateTime have a method for that?
James Jeffery
  • 2,011
  • 4
  • 19
  • 15
147
votes
7 answers

How to extract epoch from LocalDate and LocalDateTime?

How do I extract the epoch value to Long from instances of LocalDateTime or LocalDate? I've tried the following, but it gives me other results: LocalDateTime time = LocalDateTime.parse("04.02.2014 19:51:01", DateTimeFormatter.ofPattern("dd.MM.yyyy…
user1019830
143
votes
10 answers

Convert timestamp in milliseconds to string formatted time in Java

I am trying to convert a long value (number of milliseconds elapsed from 1/1/1970 i.e. Epoch) to time of format h:m:s:ms. The long value I use as timestamp, I get from the field timestamp of a logging event from log4j. So far I've tried the…
Cratylus
  • 52,998
  • 69
  • 209
  • 339
122
votes
6 answers

PostgreSQL: how to convert from Unix epoch to date?

The statement gives me the date and time. How could I modify the statement so that it returns only the date (and not the time)? SELECT to_timestamp( TRUNC( CAST( epoch_ms AS bigint ) / 1000 ) );
sid_com
  • 24,137
  • 26
  • 96
  • 187
117
votes
3 answers

Converting epoch time with milliseconds to datetime

I have used a ruby script to convert iso time stamp to epoch, the files that I am parsing has following time stamp structure: 2009-03-08T00:27:31.807 Since I want to keep milliseconds I used following ruby code to convert it to epoch time:…
add-semi-colons
  • 18,094
  • 55
  • 145
  • 232
111
votes
8 answers

Convert Unix Epoch Time to Date in Google Sheets

I have a sheet with a column of unix epoch times (in seconds): 1500598288 How can I convert these into normal dates?
Mike Bjorge
  • 1,941
  • 2
  • 11
  • 13
1
2 3
95 96