tastech Posted July 10, 2011 Share Posted July 10, 2011 I'm trying to get a form working that automatically inserts the current time into field when it's opened i.e. adding record. However I'm having a strange thing happen that I can't work out. Basically if I use the time() function I get (95% of the time) 7 minutes past the hour. So at 14:00 it returns 14:07 and keeps returning 14:07 throughout the hour until 15:00 then it returns 15:07. I can close the form, close the browser but it still has this problem. I've created a plain page with the following <?php $showtime = 0; $showtime = date("H:m", time()); echo $showtime; ?> Every time I refresh this page the time behaves as described above. As I type this I refresh it again. My MS computer shows 14:53 and my unix server shows 14:53 but this function returns 14:07. I don't believe that it's a PC thing or browser thing as I've tried several different PC/Laptops and browsers. Link to comment https://forums.phpfreaks.com/topic/241616-strange-problem-with-time/ Share on other sites More sharing options...
.josh Posted July 10, 2011 Share Posted July 10, 2011 that's because 'm' is for month. Link to comment https://forums.phpfreaks.com/topic/241616-strange-problem-with-time/#findComment-1241014 Share on other sites More sharing options...
jcbones Posted July 11, 2011 Share Posted July 11, 2011 I think you are looking for "H:i", Date Function Link to comment https://forums.phpfreaks.com/topic/241616-strange-problem-with-time/#findComment-1241026 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.