Forum Moderators: coopster

Message Too Old, No Replies

Date

Not Coming Out As I Want

         

DJ_Prem

5:15 am on Sep 6, 2003 (gmt 0)

10+ Year Member



I'm using the code below to display a date

<?PHP
$date = getdate();
$month = $date['month'];
$day = $date['mday'];
$year = $date['year'];
$dayofweek = $date['weekday'];
$hour = $date['hours'];
$min = $date['minutes'];
$sec = $date['seconds'];

print "$dayofweek, $day/$month/$year - $hour:$min:$sec";

?>

for example the date will display as

Saturday, 6/September/2003 - 6:9:7

whilst i want it to display as

Saturday, 06/September/2003 - 06:09:07

How do i do so? I've trying changing the date attributers but that does not work

AprilS

5:28 am on Sep 6, 2003 (gmt 0)

10+ Year Member



one option would be to check the lenght of the variable before printing it...if the lenght is one...print a 0.

now....if you want to be easy on yourself...go to www.php.net and learn about the "fprintf" function! ;-)

BergtheRed

6:20 pm on Sep 6, 2003 (gmt 0)

10+ Year Member



or use the date(); function. it gives you a lot more formating options including the padded day format your looking for.