zgkhoo Posted November 3, 2007 Share Posted November 3, 2007 how to find out system date & time? thanks Link to comment https://forums.phpfreaks.com/topic/75897-solved-how-to-find-out-system-date-time/ Share on other sites More sharing options...
corillo181 Posted November 3, 2007 Share Posted November 3, 2007 echo date(); Link to comment https://forums.phpfreaks.com/topic/75897-solved-how-to-find-out-system-date-time/#findComment-384123 Share on other sites More sharing options...
Barand Posted November 3, 2007 Share Posted November 3, 2007 and provide a format string <?php echo date('Y-m-d H:i:s'); ?> Link to comment https://forums.phpfreaks.com/topic/75897-solved-how-to-find-out-system-date-time/#findComment-384129 Share on other sites More sharing options...
zgkhoo Posted November 3, 2007 Author Share Posted November 3, 2007 wat is the format to save it in mysql DB? DateJoin date, <---this? is it any special format needed in mysql if date combine with time? thanks ... Link to comment https://forums.phpfreaks.com/topic/75897-solved-how-to-find-out-system-date-time/#findComment-384138 Share on other sites More sharing options...
Barand Posted November 3, 2007 Share Posted November 3, 2007 If you only need the date part DateJoin DATE, If you want time element also DateJoin DATETIME, Store them in the format I used in my previous post (omitting the H:i:s if DATE type) Link to comment https://forums.phpfreaks.com/topic/75897-solved-how-to-find-out-system-date-time/#findComment-384139 Share on other sites More sharing options...
zgkhoo Posted November 3, 2007 Author Share Posted November 3, 2007 <?php if(isset($_POST['create_feedback'])){ echo"create feedbak"; $sql = "CREATE TABLE feedback ( FID varchar(10), Topic varchar(50), Message varchar(500), DatePost datetime, UserID varchar(10), Primary Key(FID) )"; mysql_query($sql,$con); } ?> <?php $datepost=date('Y-m-d H:i:s'); //finding the sys date $sql="INSERT INTO feedback (FID,UserID,Topic,Message,DatePost) VALUES ('$FID','1234','$_POST[topic]','$_POST[message]',$datepost)"; mysql_query($sql,$con); ?> still cant... :-\ Link to comment https://forums.phpfreaks.com/topic/75897-solved-how-to-find-out-system-date-time/#findComment-384160 Share on other sites More sharing options...
zgkhoo Posted November 3, 2007 Author Share Posted November 3, 2007 sorry, my mistake ,problem solved thanks no increment to $FID Link to comment https://forums.phpfreaks.com/topic/75897-solved-how-to-find-out-system-date-time/#findComment-384162 Share on other sites More sharing options...
Barand Posted November 3, 2007 Share Posted November 3, 2007 If you want to write the current datetime when inserting you can use MySQL NOW() function. To auto_inc the FID column, write NULL to it $sql="INSERT INTO feedback (FID,UserID,Topic,Message,DatePost) VALUES (NULL, '1234', '$_POST', '$_POST[message]', NOW() )"; Link to comment https://forums.phpfreaks.com/topic/75897-solved-how-to-find-out-system-date-time/#findComment-384197 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.