Questions tagged [timestamp]

A timestamp is the time at which an event is recorded by a computer system. The timestamp term may also refer to Unix Time or to the timestamp data type.

A timestamp is a sequence of characters, denoting the date and/or time at which a certain event occurred. A timestamp is the time at which an event is recorded by a computer, not the time of the event itself. In many cases, the difference may be inconsequential: the time at which an event is recorded by a timestamp (e.g., entered into a log file) should be very, very close to the time of the occurrence of the event recorded.

In some cases, a timestamp can be just the numbering of events, the use of a date_time format to store a timestamp is then not mandatory.

This data is usually presented in a consistent format, allowing for easy comparison of two different records and tracking progress over time; the practice of recording timestamps in a consistent manner along with the actual data is called timestamping.

Timestamps are typically used for logging events, in which case each event in a log is marked with a timestamp. In filesystems, timestamp may mean the stored date/time of creation or modification of a file.


Examples of timestamps

  • 2005-10-30 T 10:45 UTC
  • 2007-11-09 T 11:20 UTC
  • Sat Jul 23 02:16:57 2005
  • 1256953732

Standardization

ISO 8601 standardizes the representation of dates and times. These standard representations are often used to construct timestamp values.


References

13570 questions
283
votes
12 answers

Convert datetime to Unix timestamp and convert it back in python

I have dt = datetime(2013,9,1,11), and I would like to get a Unix timestamp of this datetime object. When I do (dt - datetime(1970,1,1)).total_seconds() I got the timestamp 1378033200. When converting it back using datetime.fromtimestamp I got…
kun
  • 3,917
  • 3
  • 15
  • 21
270
votes
9 answers

How to get current timestamp in string format in Java? "yyyy.MM.dd.HH.mm.ss"

How to get timestamp in string format in Java? "yyyy.MM.dd.HH.mm.ss" String timeStamp = new SimpleDateFormat("yyyy.MM.dd.HH.mm.ss").format(new Timestamp()); This is what I have, but Timestamp() requires an parameters...
user3388884
  • 4,748
  • 9
  • 25
  • 34
267
votes
11 answers

Java: Date from unix timestamp

I need to convert a unix timestamp to a date object. I tried this: java.util.Date time = new java.util.Date(timeStamp); Timestamp value is: 1280512800 The Date should be "2010/07/30 - 22:30:00" (as I get it by PHP) but instead I get Thu Jan 15…
Ariyan
  • 14,760
  • 31
  • 112
  • 175
267
votes
13 answers

Python UTC datetime object's ISO format doesn't include Z (Zulu or Zero offset)

Why python 2.7 doesn't include Z character (Zulu or zero offset) at the end of UTC datetime object's isoformat string unlike JavaScript? >>> datetime.datetime.utcnow().isoformat() '2013-10-29T09:14:03.895210' Whereas in javascript >>>…
Murali Mopuru
  • 6,086
  • 5
  • 33
  • 51
262
votes
4 answers

How to convert integer timestamp into a datetime

I have a data file containing timestamps like "1331856000000". Unfortunately, I don't have a lot of documentation for the format, so I'm not sure how the timestamp is formatted. I've tried Python's standard datetime.fromordinal() and…
Cerin
  • 60,957
  • 96
  • 316
  • 522
256
votes
6 answers

Using current time in UTC as default value in PostgreSQL

I have a column of the TIMESTAMP WITHOUT TIME ZONE type and would like to have that default to the current time in UTC. Getting the current time in UTC is easy: postgres=# select now() at time zone 'utc'; timezone …
Wichert Akkerman
  • 4,918
  • 2
  • 23
  • 30
253
votes
18 answers

iPhone: How to get current milliseconds?

What is the best way to get the current system time milliseconds?
phil
238
votes
2 answers

SQL: Subtracting 1 day from a timestamp date

I am using Datagrip for Postgresql. I have a table with a date field in timestamp format (ex: 2016-11-01 00:00:00). I want to be able to: apply a mathematical operator to subtract 1 day filter it based on a time window of today-130 days display…
J-Ko
  • 2,503
  • 3
  • 9
  • 6
229
votes
6 answers

How to get correct timestamp in C#

I would like to get valid timestamp in my application so I wrote: public static String GetTimestamp(DateTime value) { return value.ToString("yyyyMMddHHmmssffff"); } // ...later on in the code String timeStamp = GetTimestamp(new…
Wojciech Ketrzynski
  • 2,503
  • 2
  • 15
  • 12
227
votes
5 answers

Ruby/Rails: converting a Date to a UNIX timestamp

How would I get a UNIX timestamp (number of seconds since 1970 GMT) from a Date object in a Rails app? I know Time#to_i returns a timestamp, but doing Date#to_time and then getting the timestamp results in something that's off by about a month (not…
igul222
  • 8,557
  • 14
  • 52
  • 60
224
votes
6 answers

How do I automatically update a timestamp in PostgreSQL

I want the code to be able to automatically update the time stamp when a new row is inserted as I can do in MySQL using CURRENT_TIMESTAMP. How will I be able to achieve this in PostgreSQL? CREATE TABLE users ( id serial not null, firstname…
Aaron
  • 11,239
  • 18
  • 58
  • 73
221
votes
7 answers

git rebase without changing commit timestamps

Would it make sense to perform git rebase while preserving the commit timestamps? I believe a consequence would be that the new branch will not necessarily have commit dates chronologically. Is that theoretically possible at all? (e.g. using…
Olivier Verdier
  • 46,998
  • 29
  • 98
  • 90
213
votes
5 answers

Plotting time on the independent axis

I have an array of timestamps in the format (HH:MM:SS.mmmmmm) and another array of floating point numbers, each corresponding to a value in the timestamp array. Can I plot time on the x axis and the numbers on the y-axis using Matplotlib? I was…
randomThought
  • 6,203
  • 15
  • 56
  • 72
212
votes
6 answers

How to format current time using a yyyyMMddHHmmss format?

I'm trying to format the current time using this format yyyyMMddHHmmss. t := time.Now() fmt.Println(t.Format("yyyyMMddHHmmss")) That is outputting: yyyyMMddHHmmss Any suggestions?
sergserg
  • 21,716
  • 41
  • 129
  • 182
193
votes
3 answers

What does the 'Z' mean in Unix timestamp '120314170138Z'?

I have an X.509 certificate which has the following 2 timestamps: ['validFrom'] = String(13) "120314165227Z" ['validTo'] = String(13) "130314165227Z" What does the postfix character 'Z' mean. Does it specify the timezone?
HomeCoder
  • 2,465
  • 3
  • 18
  • 20