Jump to content

date() convertion


chitara

Recommended Posts

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:52

But I want to isolate date & time value like Date: 2006-11-20 & Time: 05:17:52

please tell me how can i do that????

Regards
Link to comment
https://forums.phpfreaks.com/topic/28052-date-convertion/
Share on other sites

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

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.