Jump to content

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.