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
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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.