yandoo Posted January 10, 2007 Share Posted January 10, 2007 Hi, ive used the following code to enable the time time automatically appear in a text field on a form. <?php $now = getdate(time('G'));echo $now['hours'] . ":" . $now['minutes'] . ":" . $now['seconds'];?> The problem is this, it appears as 11:7:01 I need the time to appear as 11:07:01 requiring the extra 0 digit to be added! If the time in mins is 11:10:01 then its ok, it is just when the time in mins is before 10 the 0 digit doesnt appear...I need it to fulfill the format requirements by mysql. Many ThanksTom Please help Quote Link to comment Share on other sites More sharing options...
taith Posted January 10, 2007 Share Posted January 10, 2007 not tested, but should work :-)[code]<?php $now = getdate(time('G'));$hours = $now['hours'];$minutes = str_pad($now['minutes'], 2, "0", STR_PAD_LEFT); $seconds = str_pad($now['seconds'], 2, "0", STR_PAD_LEFT); echo $hours.":". $minutes.":".$seconds;?> [/code] Quote Link to comment Share on other sites More sharing options...
ted_chou12 Posted January 10, 2007 Share Posted January 10, 2007 remove the   stuff,(*both of them) btw, i still think there is a bug with this forum... Quote Link to comment 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.