Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PHP TWIG date(H:i:s) from seconds

Tags:

php

twig

symfony

I am doing a project on symfony and I need to display time with format hours:minutes:seconds from a variable that holds only seconds.

Curretly I have this: $time_in_seconds|date('H:i:s')

And the problem is that it always shows at least 01 hours... and I want it to show 00 if there is no hours present.

Even if I manually do 100|date('H:i:s') it returns 01:01:40 instead of 00:01:40.

like image 749
Gosho Avatar asked Oct 18 '25 18:10

Gosho


1 Answers

It seems it has something to do with timezones so when I specified +00:00 GMT it fixed it.

$time_in_seconds|date('H:i:s', '+00:00 GMT')
like image 181
Gosho Avatar answered Oct 20 '25 08:10

Gosho



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!