npsari Posted April 29, 2008 Share Posted April 29, 2008 Hello everybody I use this to display time $tim = localtime(time(),true); $Time=($tim['tm_hour'].":".$tim['tm_min'].":".$tim['tm_sec']); But when i print $Time i get it like that 4:32:1 I want to get it like that 04:32:01 Can you please tell me what can i change Link to comment https://forums.phpfreaks.com/topic/103377-solved-display-time-in-php/ Share on other sites More sharing options...
Gamic Posted April 29, 2008 Share Posted April 29, 2008 <?php $tim=localtime(time(),true); //check to see if we need to add 0's at the front of our display foreach($tim as $key=> $value){ if($value<10){ $tim[$key]="0$value"; } } $Time=($tim['tm_hour'].":".$tim['tm_min'].":".$tim['tm_sec']); echo "$Time"; ?> Link to comment https://forums.phpfreaks.com/topic/103377-solved-display-time-in-php/#findComment-529405 Share on other sites More sharing options...
npsari Posted April 29, 2008 Author Share Posted April 29, 2008 That is just great man, many thanks Gamic Link to comment https://forums.phpfreaks.com/topic/103377-solved-display-time-in-php/#findComment-529414 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.