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:

11787 questions
2829
votes
39 answers

Should I use the datetime or timestamp data type in MySQL?

Would you recommend using a datetime or a timestamp field, and why (using MySQL)? I'm working with PHP on the server side.
koni
  • 38,096
  • 13
  • 51
  • 77
844
votes
24 answers

How can one change the timestamp of an old commit in Git?

The answers to How to modify existing, unpushed commits? describe a way to amend previous commit messages that haven't yet been pushed upstream. The new messages inherit the timestamps of the original commits. This seems logical, but is there a…
Dhskjlkakdh
  • 8,941
  • 5
  • 20
  • 16
518
votes
20 answers

NOW() function in PHP

Is there a PHP function that returns the date and time in the same format as the MySQL function NOW()? I know how to do it using date(), but I am asking if there is a function only for this. For example, to return: 2009-12-01 00:00:00
MoeAmine
  • 5,476
  • 2
  • 15
  • 20
478
votes
14 answers

How to get the unix timestamp in C#

I have had look around stackoverflow, and even looked at some of the suggested questions and none seem to answer, how do you get a unix timestamp in C#?
bizzehdee
  • 17,878
  • 9
  • 41
  • 70
439
votes
11 answers

Create timestamp variable in bash script

I am trying to create a timestamp variable in a shell script to make the logging a little easier. I want to create the variable at the beginning of the script and have it print out the current time whenever I issue echo $timestamp. It proving to be…
Dan
  • 8,963
  • 4
  • 18
  • 34
429
votes
3 answers

In Ruby on Rails, what's the difference between DateTime, Timestamp, Time and Date?

In my experience, getting dates/times right when programming is always fraught with danger and difficulity. Ruby and Rails have always eluded me on this one, if only due to the overwhelming number of options; I never have any idea which I should…
Nick
  • 4,449
  • 3
  • 14
  • 8
397
votes
6 answers

How to convert a unix timestamp (seconds since epoch) to Ruby DateTime?

How do you convert a Unix timestamp (seconds since epoch) to Ruby DateTime?
Tronathan
  • 5,654
  • 4
  • 19
  • 24
397
votes
9 answers

How to parse/format dates with LocalDateTime? (Java 8)

Java 8 added a new java.time API for working with dates and times (JSR 310). I have date and time as string (e.g. "2014-04-08 12:30"). How can I obtain a LocalDateTime instance from the given string? After I finished working with the LocalDateTime…
micha
  • 42,796
  • 15
  • 68
  • 78
364
votes
19 answers

How to convert date to timestamp in PHP?

How do I get timestamp from e.g. 22-09-2008?
Wizard4U
  • 3,797
  • 4
  • 17
  • 14
291
votes
7 answers

Extract date (yyyy/mm/dd) from a timestamp in PostgreSQL

I want to extract just the date part from a timestamp in PostgreSQL. I need it to be a postgresql DATE type so I can insert it into another table that expects a DATE value. For example, if I have 2011/05/26 09:00:00, I want 2011/05/26 I tried…
keren
  • 2,977
  • 2
  • 13
  • 7
271
votes
18 answers

Creation timestamp and last update timestamp with Hibernate and MySQL

For a certain Hibernate entity we have a requirement to store its creation time and the last time it was updated. How would you design this? What data types would you use in the database (assuming MySQL, possibly in a different timezone that the…
ngn
  • 7,112
  • 6
  • 24
  • 33
264
votes
13 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,162
  • 3
  • 18
  • 26
254
votes
10 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…
RYN
  • 13,462
  • 29
  • 105
  • 163
254
votes
30 answers

Converting timestamp to time ago in PHP e.g 1 day ago, 2 days ago...

I am trying to convert a timestamp of the format 2009-09-12 20:57:19 and turn it into something like 3 minutes ago with PHP. I found a useful script to do this, but I think it's looking for a different format to be used as the time variable. The…
willdanceforfun
  • 10,074
  • 30
  • 80
  • 118
234
votes
18 answers

iPhone: How to get current milliseconds?

What is the best way to get the current system time milliseconds?
phil
1
2 3
99 100