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

[email protected] Wed, 30 Jun 2021 05:58:22 -0400
Newsgroups comp.lang.php,alt.comp.lang.php,alt.php
Organization Newshosting.com - Highest quality at a great price! www.newshosting.com
Message-ID <[email protected]>
On Tue, 29 Jun 2021 21:01:57 +0200, "J.O. Aho" <[email protected]>
wrote:

>
>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).

Yeah, I think.

I used this code:

<p>Date/Time: YYYY-MM-DD hh:mm<br>
<?php echo(strftime("%Y-%m-%d %H:%M")); ?></p>

and it produced this output:

Date/Time: YYYY-MM-DD hh:mm
2021-06-30 05:38

So the above output is the format I want, and it is in my time zone. I
was able to make it so that PHP uses my time zone, even though the
server is far away. What I'll want is the actual date/time string, and
I figure that I can cut out the other part that's before it.

I've been spending a lot of time trying to figure this all out. Right
now I'm thinking that using something like "filemtime" is going to
give me what I want. So far I am not having any luck with it though.

What I need to do is get the PHP script, when I can hammer it out,
into a HTML file and have the file display its own modification time.

>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

Yes, I've looked at that and I have the server using my time zone for
PHP output. Thanks for that and thanks for replying.