chitara Posted November 22, 2006 Share Posted November 22, 2006 hello Guys,In my mysql database I store the date value as $date =date('y-m-d, h-i-s');mysql_query( "INSERT INTO tb_user( entery_date, user_name) VALUES('$date', '$sender')" );So it stores the date value as 2006-11-20 05:17:52But I want to isolate date & time value like Date: 2006-11-20 & Time: 05:17:52please tell me how can i do that????Regards Link to comment https://forums.phpfreaks.com/topic/28052-date-convertion/ Share on other sites More sharing options...
Philip Posted November 22, 2006 Share Posted November 22, 2006 $date = "Date: " . date('y-m-d'). " & Time: ". date('h:i:s'); Link to comment https://forums.phpfreaks.com/topic/28052-date-convertion/#findComment-128331 Share on other sites More sharing options...
chitara Posted November 22, 2006 Author Share Posted November 22, 2006 hi!as my mysql table formate is>>CREATE TABLE `tb_user` ( `usr_no` int(11) NOT NULL auto_increment, `entry_date` datetime default NULL, `user_name` varchar(100) default NULL, PRIMARY KEY (`usr_no`),KEY `user_name` (`user_name`)) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=75 ;so its not working:-(any suggestion please... Link to comment https://forums.phpfreaks.com/topic/28052-date-convertion/#findComment-128334 Share on other sites More sharing options...
Philip Posted November 22, 2006 Share Posted November 22, 2006 `entry_date` datetime default NULLIf you want it to be in 'Date: 2006-11-20 & Time: 05:17:52' format, with text and other numbers you need to make it a varchar(33) instead of datetime Link to comment https://forums.phpfreaks.com/topic/28052-date-convertion/#findComment-128336 Share on other sites More sharing options...
printf Posted November 22, 2006 Share Posted November 22, 2006 Just do it in the database...[code]SELECT CONCAT('Date: ', DATE(entry_date), ' & Time: ', TIME(entry_date)) formatted_date FROM tb_user;[/code]// output... $row['formatted_date'][code]Date: 2006-11-20 & Time: 05:17:52[/code]or as two different values...[code]SELECT CONCAT('Date: ', DATE(entry_date)) AS new_date, CONCAT('Time: ', TIME(entry_date)) new_time FROM tb_user;[/code]// output... $row['new_date'][code]Date: 2006-11-20[/code]// output... $row['new_time'][code]Time: 05:17:52[/code]printf Link to comment https://forums.phpfreaks.com/topic/28052-date-convertion/#findComment-128337 Share on other sites More sharing options...
chitara Posted November 22, 2006 Author Share Posted November 22, 2006 its ok...but is it possible only to display date: 2006-11-20 from the exisitng format???please tell me. Link to comment https://forums.phpfreaks.com/topic/28052-date-convertion/#findComment-128339 Share on other sites More sharing options...
printf Posted November 22, 2006 Share Posted November 22, 2006 You don't want => [b]date:[/b]Then...[code]SELECT DATE(entry_date) AS new_date, TIME(entry_date) new_time FROM tb_user;[/code]// output... $row['new_date'][code]2006-11-20[/code]// output... $row['new_time'][code]05:17:52[/code]printf Link to comment https://forums.phpfreaks.com/topic/28052-date-convertion/#findComment-128340 Share on other sites More sharing options...
chitara Posted November 22, 2006 Author Share Posted November 22, 2006 thanks a lot:-DThats I wanted.Regards. Link to comment https://forums.phpfreaks.com/topic/28052-date-convertion/#findComment-128356 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.