limitphp Posted November 3, 2008 Share Posted November 3, 2008 I'm using the strtotime function in php to store some dates that I'll be comparing against other dates. What type should I use in MYSQL to store these timestamps? Thanks mysql 5.0.5 Link to comment https://forums.phpfreaks.com/topic/131225-solved-when-using-strtotime-what-type-do-you-use-in-mysql/ Share on other sites More sharing options...
limitphp Posted November 3, 2008 Author Share Posted November 3, 2008 I see a timestamp in MYSQL, but I was reading that this is different from the timestamp in php. Will it cause problems if I store it as a timestamp in MYSQL? Link to comment https://forums.phpfreaks.com/topic/131225-solved-when-using-strtotime-what-type-do-you-use-in-mysql/#findComment-681300 Share on other sites More sharing options...
Mchl Posted November 3, 2008 Share Posted November 3, 2008 MySQL's TIMESTAMP is a bit different from PHP timestamp (being UNIX timestamp) but there will be no problems interfacing the two, as long as you know some functions For example FORM_UNIXTIME() that you can use to save Unix timestamp into MySQL TIMESTAMP (or DATETIME), and UNIX_TIMESTAMP() that will work the other way. There also PHP functions that enable you to do the same. Link to comment https://forums.phpfreaks.com/topic/131225-solved-when-using-strtotime-what-type-do-you-use-in-mysql/#findComment-681304 Share on other sites More sharing options...
limitphp Posted November 3, 2008 Author Share Posted November 3, 2008 Actually, I just readom seomwhere that it should be INT. Because the php strtotime will produce a number....and i'll be making comparisons on this number. Math comparisons. Link to comment https://forums.phpfreaks.com/topic/131225-solved-when-using-strtotime-what-type-do-you-use-in-mysql/#findComment-681306 Share on other sites More sharing options...
discomatt Posted November 3, 2008 Share Posted November 3, 2008 You're better off using MySQL's timestamp type column... Link to comment https://forums.phpfreaks.com/topic/131225-solved-when-using-strtotime-what-type-do-you-use-in-mysql/#findComment-681309 Share on other sites More sharing options...
Mchl Posted November 3, 2008 Share Posted November 3, 2008 You're better off using MySQL's timestamp type column... because on TIMESTAMP you can do time comparisons... that's better than math comparisons (which you can do as well) Link to comment https://forums.phpfreaks.com/topic/131225-solved-when-using-strtotime-what-type-do-you-use-in-mysql/#findComment-681324 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.