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

python: convert year/month/day/hour/min/second to # seconds since Jan 1 1970

I know how to do it in C and Java, but I don't know a quick way of converting year/month/day/hour/min/second to the # of seconds since the Jan 1 1970 epoch. Can someone help me? So far I've figured out how to create a datetime object but I can't…
Jason S
  • 184,598
  • 164
  • 608
  • 970
8
votes
3 answers

Why is Datetime's `.timestamp()` method returning `OSError: [Errno 22] Invalid argument`?

I make use of the .timestamp() function twice in my code, to convert datetime objects into epoch time. The first call to .timestamp() looks like this: import datetime origin_epoch = origin.timestamp() the contents of the variables origin and…
David
  • 606
  • 9
  • 19
8
votes
5 answers

Converting UTC string to epoch time in javascript

How can I convert UTC date-time string (e.g. 2011-03-29 17:06:21 UTC) into Epoch (milliseconds) in javascript? If this is not possible, is there any way to compare (like <, >) UTC date time strings?
katsuya
  • 1,204
  • 3
  • 16
  • 21
8
votes
3 answers

How to convert a date time string to long (UNIX Epoch Time) in Java 8 (Scala)

I want the UNIX Epoch Time (Posix Time, Unix Time) of a string in some pattern, the string is in normal format (so UTC). Please using Java 8, not Joda or old Java. (For milliseconds please see How to convert a date time string to long (UNIX Epoch…
samthebest
  • 30,803
  • 25
  • 102
  • 142
8
votes
1 answer

Convert Unix timestamp to timestamp without time zone

How do I convert a Unix timestamp (or epoch time) to a PostgreSQL timestamp without time zone? For example, 1481294792 should convert to 2016-12-09 14:46:32. I tried SELECT to_timestamp(1481294792)::timestamp, but that gives me 2016-12-09 09:46:32.
ma11hew28
  • 121,420
  • 116
  • 450
  • 651
8
votes
1 answer

Haskell: Extract Int from POSIXTime / NominalDiffTime

I am signing web requests, and as part of the query string, I need to include oauth_timestamp=123456789 where the 123456789 is the nominal time since 1970-01-01 00:00 UTC. I have been using POSIXTime for its representation, which is just a type…
tmortiboy
  • 485
  • 3
  • 10
8
votes
1 answer

High CPU usage 130% of a CPU for fail2ban due to epoch datetime retrieval errors

Persistent overseas network attacks being performed on my system without my permission inclined me to install fail2ban since cphulkd does not ban ips. I am monitoring a few services for unwelcome penetration attempts. Once the service was started, I…
8
votes
2 answers

How to check if a timestamp is a whole hour

I'm building a python application where I get a lot of data from various timeseries (ranging from 1 minute to 1 day). I would only like to store the times (unix timestamps) that are exactly on a whole hour (xx:00 minutes). How do I build this…
Wouter Luberti
  • 105
  • 2
  • 7
8
votes
3 answers

python convert datetime formatted string to seconds

I am trying to decode a date string to epoch but I have difficulties getting the timezone. This is the last modified date from Amazon S3 keys. time.strptime(key.last_modified, '%Y-%m-%dT%H:%M:%S.%Z') ValueError: time data…
Vame
  • 2,033
  • 2
  • 18
  • 29
8
votes
2 answers

Joda - How to compare two DateTime objects without ignoring TimeZones

I am having a hard time comparing two DateTime objects that are in different TimeZones. What I already know: 1) I know that the "isBefore()" method does not take TimeZones into account. So, the "if" condition bellow is not true (even though I would…
8
votes
4 answers

How to set time to epoch time java?

I'm trying to set the time to epoch date time in java. how can I do this? so that I could get year months days etc out of the epoch date time.
Mr.Noob
  • 1,005
  • 3
  • 24
  • 58
8
votes
1 answer

Convert eg. 2012-05-25 to seconds since January 1 1970

I have a database where I save time as time() from php, which is seconds since 1 jan 1970. Is there any way I can convert, for example 2012-12-12 to seconds since 1 jan 1970? I want to do like: SELECT * FROM Table WHERE date > '2012-11-30' AND…
netdigger
  • 3,659
  • 3
  • 26
  • 49
7
votes
2 answers

Date string to epoch seconds (UTC)

Question I want to parse a date-time given as string (UTC) into seconds since epoch. Example (see EpochConverter): 2019-01-15 10:00:00 -> 1547546400 Problem The straightforward solution, which is also accepted in a very related question C++…
Zabuzard
  • 25,064
  • 8
  • 58
  • 82
7
votes
3 answers

How to convert an Epoch to a OffsetDateTime in Kotlin?

The postgresql Timestamp with Time Zone data type needs to be supplied an OffsetDateTime when being called using a High level language like Kotlin. I could not find a direct method that supports Epoch to OffsetDateTime conversion.
Raj
  • 3,637
  • 8
  • 29
  • 52
7
votes
1 answer

Working with epoch time in PowerShell using UniversalTime

This is probably a super simple question, but I'm a bit frustrated now because I can't find exactly what I'm looking for on the internet. I am trying to convert a PowerShell DateTime to Epoch time using universal time. I can do either, but can't…
Appleoddity
  • 647
  • 1
  • 6
  • 21