Jump to content

Archived

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

Fieldy

What timestamp?

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?

Share this post


Link to post
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.

Share this post


Link to post
Share on other sites
Ok, but what are the advantages of both methods? Which should i choose of these?

Share this post


Link to post
Share on other sites

×

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.