The format of timestamps used in MediaWiki URLs and in some of the MediaWiki database fields is yyyymmddhhmmss. For example, the timestamp for 2023-04-12 13:03:35 (UTC) is 20230412130335. 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 PostgreSQL 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]

Datatypes

Here are the various timestamp datatypes used in the MediaWiki core:

binary(14)

  • filearchive.fa_deleted_timestamp
  • filearchive.fa_timestamp
  • job.job_timestamp
  • job.job_token_timestamp
  • user.user_email_authenticated
  • user.user_email_token_expires
  • user_newtalk.user_last_timestamp
  • user.user_newpass_time
  • user.user_registration
  • watchlist.wl_notificationtimestamp

binary(14) NOT NULL

  • archive.ar_timestamp
  • image.img_timestamp
  • ipblocks.ipb_timestamp
  • ip_changes.ipc_rev_timestamp (introduced in 1.30)
  • msg_resource.mr_timestamp (removed in 1.27)
  • objectcache.exptime (introduced in 1.36)
  • oldimage.oi_timestamp
  • page.page_touched
  • protected_titles.pt_timestamp
  • recentchanges.rc_timestamp
  • revision.rev_timestamp
  • revision_actor_temp.revactor_timestamp (introduced in 1.31)
  • transcache.tc_time (removed in 1.32)
  • uploadstash.us_timestamp
  • user.user_touched
  • watchlist_expiry.we_expiry (introduced in 1.35)

binary(14) NOT NULL default '19700101000000'

  • logging.log_timestamp
  • querycache_info.qci_timestamp

varbinary(14)

  • page.page_links_updated
  • page_restrictions.pr_expiry
  • user.user_password_expires (introduced in 1.23)
  • user_groups.ug_expiry (introduced in 1.29)

varbinary(14) NOT NULL

  • ipblocks.ipb_expiry

varbinary(14) NOT NULL default ''

  • recentchanges.rc_cur_time (removed in 1.24)

timestamp NOT NULL

  • categorylinks.cl_timestamp

Notes

This article is issued from Mediawiki. The text is licensed under Creative Commons - Attribution - Sharealike. Additional terms may apply for the media files.