I set this at the start of the script :

date_default_timezone_set('Europe/London');
$var = date('h:m:s', mktime());
echo $var;

And it outputs this everytime, the only thing that changes is the seconds. 12:12:32 12:12:45 12:12:10

Any help with this would be great :) thanks, Pablo

up vote 0 down vote accepted

Pablo welcome to Ask Ubuntu! This Stack Exchange is designed for questions specifically about Ubuntu, for questions regarding programming like PHP, I suggest you try over at Stack Overflow in future.

Regardless, you're time format is incorrect.

h refers to the month, since we're in december, it's showing you 12.

Minutes are formatting as i

so $var = date('h:i:s', mktime()); will get you the results you need.

See the official documentation here for further info.

  • This helps alot thanks :) – Pablo Xorius Dec 2 at 12:47

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.