Jump to content

What timestamp?


Fieldy

Recommended Posts

PHP uses a timestamp in seconds from 1970 and MySQL uses a timestamp like 20061026193021. I like to save the timestamp in to a database. What is the most common way? Wich one should i choose and why? I see that PhpBB saves the PHP timestamp in a varchar field, why didn't they choose a MySQL timestamp field for it?
Link to comment
https://forums.phpfreaks.com/topic/25207-what-timestamp/
Share on other sites

PHP uses a UNIX Time stamp which is the number of seconds passed since 1st Jan 1970

I use UNIX timestamps, by using the time() function to get the timestamp of now or use strtotime to convert a date format into a time stamp, eg 12/06/2006 (dd/mm/yyyy) into a UNIX timestamp which produces the follow: 1165363200

I generally use INT as the data type when storing timestamps in MySQL. However you can use a TIMESTAMP as the data type if you want to. Its up to you when creating your database schema.
Link to comment
https://forums.phpfreaks.com/topic/25207-what-timestamp/#findComment-114964
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.