Re: Newbie needs recommendation for fast learning a little php.

"J.O. Aho" <[email protected]> Tue, 29 Jun 2021 21:01:57 +0200
Newsgroups comp.lang.php,alt.comp.lang.php,alt.php
Message-ID <[email protected]>
On 29/06/2021 16.30, [email protected] wrote:
> I mostly need to do a specific thing, get a file to
> display its last modified date and time inside itself.
 >
> I used to use ssi for this, but I moved to a new Web host and they
> seem to have their server time zone set as the only time zone I can
> display, and they are far away from me, so in ssi I get a date and
> time for a file modification time that's many hours off. 

I'm assuming you got the PHP code to work to show the date (even if it's 
the wrong timezone for you).

If you have stored the date in a variable $lastmodified then you could 
use the following code to adjust it:

$date = date_create($lastmodified, timezone_open('Pacific/Nauru'));
echo date_format($date, 'Y-m-d H:i:sP');

Just use a valid timezone name to replace the Pacific/Nauru. Keep in 
mind that the time may look off for other users who do not live in the 
timezone you want to display.

For more information about datetime and timezone check the following 
page at php.net:

https://www.php.net/manual/en/datetime.settimezone.php


-- 

  //Aho