Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

php date strange behaviour

Tags:

date

php

I have this code

$daytime=date("D M j G:i:s T Y");

anyone can explain me why in some server the value T returns something like this

Tue Oct 10 12:30:50 -03 2017

while in another server the value T returns something like this

Tue Oct 10 12:30:50 CDT 2017

How can I do to always display the CDT value instead of the numeric value -03 ?

Thank you

like image 615
gr68 Avatar asked Jun 21 '26 11:06

gr68


1 Answers

Dump the result of date_default_timezone_get() on both servers and see the difference. It depends which timezone identifier your server is set to. Some timezone identifiers will display as +xx or -xx when using the T modifier, while identifiers will be abbreviated.

If you want to force a specific timezone in your application without changing server configuration, you can set it using date_default_timezone_set().

like image 109
chocochaos Avatar answered Jun 24 '26 01:06

chocochaos



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!