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
188
votes
9 answers

Why there can be only one TIMESTAMP column with CURRENT_TIMESTAMP in DEFAULT clause?

Why there can be only one TIMESTAMP column with CURRENT_TIMESTAMP in DEFAULT or ON UPDATE clause? CREATE TABLE `foo` ( `ProductID` INT(10) UNSIGNED NOT NULL, `AddedDate` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, `UpdatedDate` TIMESTAMP NOT…
ripper234
  • 222,824
  • 274
  • 634
  • 905
188
votes
5 answers

How to get current timestamp in milliseconds since 1970 just the way Java gets

In Java, we can use System.currentTimeMillis() to get the current timestamp in Milliseconds since epoch time which is - the difference, measured in milliseconds, between the current time and midnight, January 1, 1970 UTC. In C++ how to get the…
AKIWEB
  • 19,008
  • 67
  • 180
  • 294
184
votes
3 answers

How to convert java.sql.timestamp to LocalDate (java8) java.time?

In Java 8, how can I convert a Timestamp (in java.sql) to a LocalDate (in java.time)?
simonides
  • 3,040
  • 3
  • 19
  • 34
181
votes
7 answers

How to have an automatic timestamp in SQLite?

I have an SQLite database, version 3 and I am using C# to create an application that uses this database. I want to use a timestamp field in a table for concurrency, but I notice that when I insert a new record, this field is not set, and is…
Álvaro García
  • 18,114
  • 30
  • 102
  • 193
178
votes
12 answers

How do I convert dmesg timestamp to custom date format?

I am trying to understand the dmesg timestamp and find it hard to convert that to change it to java date/custom date format. Sample dmesg log: [14614.647880] airo(eth1): link lost (missed beacons) So how do I convert 14614.647880 to a standard…
ukanth
  • 2,718
  • 5
  • 28
  • 38
177
votes
4 answers

Ignoring time zones altogether in Rails and PostgreSQL

I'm dealing with dates and times in Rails and Postgres and running into this issue: The database is in UTC. The user sets a time-zone of choice in the Rails app, but it's only to be used when getting the users local time for comparing times. User…
99miles
  • 10,942
  • 18
  • 78
  • 123
177
votes
1 answer

What exactly does the T and Z mean in timestamp?

I have this timestamp value being return by a web service "2014-09-12T19:34:29Z" I know that it means timezone, but what exactly does it mean? And I am trying to mock this web service, so is there a way to generate this timestamp using strftime in…
roymustang86
  • 8,054
  • 22
  • 70
  • 101
165
votes
9 answers

How to get UTC timestamp in Ruby?

How to get UTC timestamp in Ruby?
Mohit Jain
  • 43,139
  • 57
  • 169
  • 274
162
votes
4 answers

MySQL convert date string to Unix timestamp

How do I convert the following format to unix timestamp? Apr 15 2012 12:00AM The format I get from DB seems to have AM at the end. I've tried using the following but it did not work: CONVERT(DATETIME, Sales.SalesDate, 103) AS DTSALESDATE, …
redcoder
  • 2,233
  • 4
  • 22
  • 24
159
votes
9 answers

Get current time as formatted string in Go?

What's the best way to get the current timestamp in Go and convert to string? I need both date and time in eg. YYYYMMDDhhmmss format.
brianoh
  • 3,407
  • 6
  • 23
  • 23
158
votes
12 answers

'0000-00-00 00:00:00' can not be represented as java.sql.Timestamp error

I have a database table containing dates (`date` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00'). I'm using MySQL. From the program sometimes data is passed without the date to the database. So, the date value is auto assigned to 0000-00-00…
Chamila Adhikarinayake
  • 3,588
  • 5
  • 25
  • 32
156
votes
7 answers

Convert LocalDate to LocalDateTime or java.sql.Timestamp

I am using JodaTime 1.6.2. I have a LocalDate that I need to convert to either a (Joda) LocalDateTime, or a java.sqlTimestamp for ormapping. The reason for this is I have figured out how to convert between a LocalDateTime and a…
IAmYourFaja
  • 55,468
  • 181
  • 466
  • 756
155
votes
7 answers

What does this format mean T00:00:00.000Z?

Can someone, please, explain this type of format in javascript T00:00:00.000Z And how to parse it?
Ali Akram
  • 4,803
  • 3
  • 29
  • 38
155
votes
7 answers

Performance - Date.now() vs Date.getTime()

var timeInMs = Date.now(); per MDN vs. var timeInMs = new Date(optional).getTime(); per MDN. Is there any difference between the two, besides the syntax and the ability to set the Date (to not the current) via optional in the second…
user656925
153
votes
18 answers

Getting date format m-d-Y H:i:s.u from milliseconds

I am trying to get a formatted date, including the microseconds from a UNIX timestamp specified in milliseconds. The only problem is I keep getting 000000, e.g. $milliseconds = 1375010774123; $d = date("m-d-Y H:i:s.u", $milliseconds/1000); print…
slik
  • 5,001
  • 6
  • 34
  • 40