By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
429,515 Members | 1,339 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 429,515 IT Pros & Developers. It's quick & easy.

Time format in php

P: 6
hi guys,
I want to display time format 22:00 instead of 00:22:00 as stored in mysql. I am using mysql and php. data type in php is time not timestamp. thnx in advance for help
Dec 24 '07 #1
Share this Question
Share on Google+
1 Reply


realin
100+
P: 254
hi guys,
I want to display time format 22:00 instead of 00:22:00 as stored in mysql. I am using mysql and php. data type in php is time not timestamp. thnx in advance for help

hello tamimmakki,

well its very simple to do that.. fetch the datetime from mysql, change it to string and then use date function to display the way you want.. Though, i would advice you to store date & time into VARCHAR format in mysql, so u can skip the first step.. well a working example goes in here..

[PHP]
<?php

//make connection & stuff and fetch data
$fetch=date('g:m:i');
$str=strtotime($fetch);
echo date('H:M',$str);
?>
[/PHP]

cheers !!
Dec 24 '07 #2

Post your reply

Sign in to post your reply or Sign up for a free account.