|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2002-07-02 13:11 UTC] randy at careerstep dot com
Lets say you have a directory of 1000 files give or take any number, and you want to archive (or delete) many of those files by month. Each file contains a time stamp of when it was last modified. If I create a new directory called January and take use each time stamp to tell me which ones where last modified in the month January, then it returns all files in January and Feb 1st. The same thing with all the other months. I've tried this using the date and getdate function, and have had the same problem. It acts like the date for PHP is one day off the date of FreeBSD. I've tested it on 2 different FreeBSD servers. When I use the php functions to get the time for the first of the month, everything works well. But when I use the time stamp associated with a file, then it's one day off. PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Tue Nov 04 17:00:01 2025 UTC |
Addionally, I've since descovered that when PHP gets a timestamp from a UNIX file that was created/modified on the first day of any month ( use ls -al from the command line to verify the actual date modified), PHP returns the mday (in the case of getdate()), or "d" (in the case of date()) as being the last day of the PREVIOUS month + 1 day, instead of returning 1, which is the actual day of modification/creation. It doesn't even try to claim it's day 0. It just invents an imaginary day for the previous month and returns that. It also gets the "m" (date()), or 'mon' and 'month' (getdate()) values wrong, returning them as those of the previous month. Try using date("m - d", $timestamp_from_unix_file); if you don't believe me.Addionally, I've since descovered that when PHP gets a timestamp from a UNIX file that was created/modified on the first day of any month ( use ls -al from the command line to verify the actual date modified), PHP returns the mday (in the case of getdate()), or "d" (in the case of date()) as being the last day of the PREVIOUS month + 1 day, instead of returning 1, which is the actual day of modification/creation. It doesn't even try to claim it's day 0. It just invents an imaginary day for the previous month and returns that. It also gets the "m" (date()), or 'mon' and 'month' (getdate()) values wrong, returning them as those of the previous month. Try using date("m - d", $timestamp_from_unix_file); if you don't believe me.