Timestamp From Online Manual

Revision as of 09:49, 27 March 2011 by Emanuele (talk | contribs) (Created page with "A timestamp is a way of representing times in programming languages. Usually, this is a unix timestamp, expressed as the number of seconds since midnight on December 31, 1969. As...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

A timestamp is a way of representing times in programming languages. Usually, this is a unix timestamp, expressed as the number of seconds since midnight on December 31, 1969. As an example, the timestamp of January 1, 2006 at 12:00:00 am is 1136102400.

In MySQL, you can easily work with this by using the UNIX_TIMESTAMP() and FROM_UNIXTIME() functions, which translate between dates as strings and dates as timestamps. Examples include:

SELECT UNIX_TIMESTAMP('2006-01-01 0:00:00');
SELECT FROM_UNIXTIME(1136102400);
INSERT INTO smf_members
	(memberName, realName, emailAddress, dateRegistered, passwd)
VALUES ('member', 'member', '[email protected]', UNIX_TIMESTAMP(NOW()), 
	MD5('password'));

In PHP, you can work with them by using the time(), strftime(), and strtotime() functions.



Advertisement: