jonaHill87 Posted January 8, 2008 Share Posted January 8, 2008 Hi. Just wondering how I can create a timestamp using php. I need two timestamps, one with todays date/time and another with a week from todays date/time. Then I need to stick them into 2 fields in mysql. Can anyone help me out? I dont need a big long code, I just need the timestamps and maybe a hint of how to chuck them into the fields using an INSERT mysql command and what datatypes for the fields I should be using. Thanks to anyone who helps. Quote Link to comment https://forums.phpfreaks.com/topic/85090-solved-php-timestamp/ Share on other sites More sharing options...
Ken2k7 Posted January 8, 2008 Share Posted January 8, 2008 Read up on it: http://us.php.net/manual/en/function.time.php Quote Link to comment https://forums.phpfreaks.com/topic/85090-solved-php-timestamp/#findComment-433988 Share on other sites More sharing options...
revraz Posted January 8, 2008 Share Posted January 8, 2008 First you need to decide if you want to use MySQL Date and Time format or Unix Time format. Quote Link to comment https://forums.phpfreaks.com/topic/85090-solved-php-timestamp/#findComment-433990 Share on other sites More sharing options...
GingerRobot Posted January 8, 2008 Share Posted January 8, 2008 I prefer to use an INT field to store the dates, so we can store them as a unix timestamp. <?php $now = time(); $next_week = strtotime('next week'); mysql_query("INSERT INTO tbl SET col1 = $now and col2 = $next_week") or die(mysql_error()); ?> You can then format the dates however you would like when you output them, using the date() function. Quote Link to comment https://forums.phpfreaks.com/topic/85090-solved-php-timestamp/#findComment-433991 Share on other sites More sharing options...
jonaHill87 Posted January 9, 2008 Author Share Posted January 9, 2008 edit*** thanks guys I just had to use the DATE field and it worked out. Quote Link to comment https://forums.phpfreaks.com/topic/85090-solved-php-timestamp/#findComment-434111 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.