Manual:Timestamp
The format of timestamps used in MediaWiki URLs and in some of the MediaWiki database fields is yyyymmddhhmmss
. For example, the timestamp for August 9th, 2010 00:30:06 UTC
is 20100809003006
. The timezone for these timestamps is UTC.
MediaWiki's wfTimestamp()
function provides a convenient way to convert from timestamps in common formats to the MediaWiki timestamp format and vice versa. Read Manual:wfTimestamp for more details. Never use wfTimestamp() when inserting a timestamp into the database; this will break in Postgres and possibly other non-MySQL databases. Instead use DatabaseBase::timestamp(), aka $dbw->timestamp(), which converts a timestamp in one of the formats accepted by wfTimestamp() to the format used for inserting into timestamp fields in this DBMS.
wfTimestampNow()
is a convenience function that returns a MediaWiki timestamp for the present time.
MediaWiki stores timestamps as strings rather than native timestamp types because MySQL's TIMESTAMP type had major limitations when MediaWiki was first written.[1]
DatatypesEdit
Here are the various timestamp datatypes used in the MediaWiki core:
binary(14)Edit
- user.user_email_authenticated
- user.user_email_registration
- user.user_email_token_expires
- user.user_newpass_time
binary(14) default ''Edit
binary(14) NOT NULLEdit
binary(14) NOT NULL default ''Edit
- archive.ar_timestamp
- ipblocks.ipb_timestamp
- oldimage.oi_timestamp
- page.page_touched
- revision.rev_timestamp
- user.user_touched
binary(14) NOT NULL default '19700101000000'Edit
varbinary(14)Edit
varbinary(14) NULLEdit
varbinary(14) NULL default NULLEdit
- job.job_timestamp
- job.job_token_timestamp
- page.page_links_updated
- user.user_last_timestamp
- user.user_newtalk