LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   PHP last time modified script time way off (https://www.linuxquestions.org/questions/programming-9/php-last-time-modified-script-time-way-off-34603/)

GabeF 11-04-2002 09:49 PM

PHP last time modified script time way off
 
I am just starting out with PHP, and wanted to write a very simple (how many scripts are one liners?) script to do just that. It displays the time, but the the wrong one. For example:

December 31 1969 7:00:00 when the date was actually
November 5 2002 10:50.

Anybody have any pointers? Thanks

leed_25 11-05-2002 01:22 PM

Can you show us your script? Here's what seems a little odd to me right off the bat: that date --December 31 1969 7:00:00-- is the day before the epoch --jan 1 1970 00:00:00--, so I'd be willing to bet that you're probably passing a negative number to the date print function.

GabeF 11-05-2002 08:05 PM

I just figured it out. Here was my old script:

Code:

echo date( "F d Y h:i:s", getlastmod() );
lol nice and short.

And here is my new one:

Code:

$last_modified = filemtime("<filename>");
print("Last Modified: ");
print(date("m/j/y h:i", $last_modified));

I don't see anything wrong with the first, but I don't know a whole lot about php syntax either.


All times are GMT -5. The time now is 01:40 AM.