watthehell Posted September 14, 2007 Share Posted September 14, 2007 How to get a current time from PHP time() function : When i did $my_current_time=time(); echo $my_current_time; it returns 1189757415 as the result. How to get in hour:min format i didnt find any help from PHP manual Quote Link to comment https://forums.phpfreaks.com/topic/69303-solved-how-to-get-current-time-from-php-time-function/ Share on other sites More sharing options...
phat_hip_prog Posted September 14, 2007 Share Posted September 14, 2007 $t = time(); $d = date("j \of F Y, \a\\t g.i a", $t); $d2 = date("r", $t); print "time: ".$t."<br>"; print "date: ".$d."<br>"; print "date2: ".$d2."<br>"; Quote Link to comment https://forums.phpfreaks.com/topic/69303-solved-how-to-get-current-time-from-php-time-function/#findComment-348234 Share on other sites More sharing options...
watthehell Posted September 14, 2007 Author Share Posted September 14, 2007 $t = time(); $d = date("j \of F Y, \a\\t g.i a", $t); $d2 = date("r", $t); print "time: ".$t."<br>"; print "date: ".$d."<br>"; print "date2: ".$d2."<br>"; I don't need date only time i did $t = time(); print $t; it come like this 1189757419 Quote Link to comment https://forums.phpfreaks.com/topic/69303-solved-how-to-get-current-time-from-php-time-function/#findComment-348238 Share on other sites More sharing options...
roopurt18 Posted September 14, 2007 Share Posted September 14, 2007 Why don't you try it and see what it does? Quote Link to comment https://forums.phpfreaks.com/topic/69303-solved-how-to-get-current-time-from-php-time-function/#findComment-348239 Share on other sites More sharing options...
jitesh Posted September 14, 2007 Share Posted September 14, 2007 <?php $my_current_time=time(); echo date("h:i:s",$my_current_time); ?> Quote Link to comment https://forums.phpfreaks.com/topic/69303-solved-how-to-get-current-time-from-php-time-function/#findComment-348241 Share on other sites More sharing options...
watthehell Posted September 14, 2007 Author Share Posted September 14, 2007 I tweaked your code lil' bit and finally the output was really great thanks <?php $my_current_time=date("h:i"); echo $my_current_time; ?> But another problem it returned the time as 14.20 when my pc time is 2:20. Can't we get 2.20 instead of 14 ?? Is that possible... Quote Link to comment https://forums.phpfreaks.com/topic/69303-solved-how-to-get-current-time-from-php-time-function/#findComment-348243 Share on other sites More sharing options...
phat_hip_prog Posted September 14, 2007 Share Posted September 14, 2007 Have a look at the manual! http://uk2.php.net/manual/en/function.date.php It's a very helpful place! Do you think forums make programming too easy? Quote Link to comment https://forums.phpfreaks.com/topic/69303-solved-how-to-get-current-time-from-php-time-function/#findComment-348255 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.