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
36
votes
5 answers

Convert unix epoch time to human readable date on Mac OSX - BSD

On my Mac OSX, my bash script has a epoch time 123439819723. I am able to convert the date to human readable format by date -r 123439819723 which gives me Fri Aug 26 09:48:43 EST 5881. But I want the date to be in mm/ddd/yyyy:hh:mi:ss format. The…
Nehal Shah
  • 363
  • 1
  • 3
  • 4
35
votes
7 answers

How to convert python timestamp string to epoch?

I have the following string: mytime = "2009-03-08T00:27:31.807Z" How do I convert it to epoch in python? I tried: import time p = '%Y-%m-%dT%H:%M:%S' int(time.mktime(time.strptime(s, p))) But it does not work with the 31.807Z.
Rolando
  • 58,640
  • 98
  • 266
  • 407
35
votes
1 answer

When is std::chrono epoch?

std::chrono::time_point::time_since_epoch() returns a duration, referred to some time_point in the past. When is such a time_point? It depends on the C++ implementation or it's defined by the C++ standard? Or it is a de facto standard to set the…
Paolo M
  • 12,403
  • 6
  • 52
  • 73
34
votes
7 answers

Get the number of days, weeks, and months, since Epoch in Java

I'm trying to get the number of days, weeks, months since Epoch in Java. The Java Calendar class offers things like calendar.get(GregorianCalendar.DAY_OF_YEAR), or Calendar.get(GregorianCalendar.WEEK_OF_YEAR), which is a good start but it doesn't…
Ariel Vardi
  • 797
  • 1
  • 7
  • 18
33
votes
10 answers

Converting Epoch time to date string

I have seen this question asked multiple times and none of the answers seem to be what i need. I have a long type variable which has an epoch time stored in it. What i want to do is convert it to a String for example if the epoch time stored was for…
nexus490
  • 797
  • 5
  • 11
  • 21
33
votes
2 answers

Convert mysql DATETIME column to epoch seconds

I have a column mysql datetime that is in DATETIME format. Is there a way to SELECT this column in epoch seconds? If not, what would be the best way of converting the datetime format to epoch seconds? What type of field would be the best to capture…
David542
  • 104,438
  • 178
  • 489
  • 842
32
votes
2 answers

How to convert ZonedDateTime to milliSecond in Java?

I'm trying to convert ZonedDateTime to milliseconds using below code. LocalDateTime ldt = LocalDateTime.now(); ZonedDateTime zonedDateTime =ldt.atZone(ZoneId.of(""Asia/Kolkata"")); zonedDateTime.toInstant().toEpochMilli(); But this one returns…
Arun
  • 510
  • 2
  • 5
  • 9
32
votes
3 answers

How to convert epoch time with nanoseconds to human-readable?

I have a timestamp in epoch time with nanoseconds - e.g. 1360287003083988472 nanoseconds since 1970-01-01. The Python datetime objects and conversion methods only support up to millisecond precision. Is there an easy way to convert this epoch time…
victorhooi
  • 16,775
  • 22
  • 90
  • 113
31
votes
4 answers

Which one is recommended: Instant.now().toEpochMilli() or System.currentTimeMillis()

In Java, we can have many different ways to get the current timestamp, but which one is recommended: Instant.now().toEpochMilli() or System.currentTimeMillis()
Yishu Fang
  • 9,448
  • 21
  • 65
  • 102
31
votes
7 answers

Converting epoch time to "real" date/time

What I want to do is convert an epoch time (seconds since midnight 1/1/1970) to "real" time (m/d/y h:m:s) So far, I have the following algorithm, which to me feels a bit ugly: void DateTime::splitTicks(time_t time) { seconds = time % 60; …
Austin Hyde
  • 26,347
  • 28
  • 96
  • 129
30
votes
5 answers

Convert Epoch seconds to date and time format in Java

I have seconds since 1970 january 1 UTC (Epoch time). 1320105600 I need to convert that seconds into date and time in below format. Friday,November 4,2011 5:00,AM How can I achieve this?
androiduser
  • 917
  • 3
  • 11
  • 15
27
votes
6 answers

jquery convert number to date?

i have a json file that returns "date_created":"1273185387" in epoch format i want to convert it to something like this Thu, 06 May 2010 22:36:27 GMT any script to do this conversion?
Patrioticcow
  • 26,422
  • 75
  • 217
  • 337
27
votes
5 answers

Converting TIMESTAMP to unix time in PHP?

Currently I store the time in my database like so: 2010-05-17 19:13:37 However, I need to compare two times, and I feel it would be easier to do if it were a unix timestamp such as 1274119041. (These two times are different) So how could I convert…
Rob
  • 7,980
  • 30
  • 75
  • 115
27
votes
6 answers

How can I convert a date in Epoch to "Y-m-d H:i:s" in Javascript?

How can I convert following date in epoch: 1293683278 to following readable date: 2010-06-23 09:57:58 using Javascript? Thanks!
James Cazzetta
  • 3,122
  • 6
  • 32
  • 54
26
votes
3 answers

length of System.currentTimeMillis

Does System.currentTimeMillis always returns a fixed length of value. In my windows Core2, it return a 13 digit long value. From its API: Returns the current time in milliseconds. Note that while the unit of time of the return value is a…
as.tek
  • 937
  • 3
  • 14
  • 20
1 2
3
95 96