Jump to content


Photo

What timestamp?


  • Please log in to reply
2 replies to this topic

#1 Fieldy

Fieldy
  • New Members
  • Pip
  • Newbie
  • 2 posts

Posted 26 October 2006 - 05:31 PM

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?

#2 wildteen88

wildteen88
  • Staff Alumni
  • Advanced Member
  • 10,482 posts
  • LocationUK, Bournemouth

Posted 26 October 2006 - 06:11 PM

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.

#3 Fieldy

Fieldy
  • New Members
  • Pip
  • Newbie
  • 2 posts

Posted 27 October 2006 - 05:00 PM

Ok, but what are the advantages of both methods? Which should i choose of these?




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users