php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #18115 timestamp of the 1st of one month, gets valued as previous month
Submitted: 2002-07-02 13:11 UTC Modified: 2002-07-02 15:48 UTC
Votes:6
Avg. Score:4.3 ± 0.9
Reproduced:4 of 4 (100.0%)
Same Version:2 (50.0%)
Same OS:2 (50.0%)
From: randy at careerstep dot com Assigned:
Status: Not a bug Package: Calendar related
PHP Version: 4.0CVS-2002-07-02 OS: FreeBSD
Private report: No CVE-ID: None
 [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.

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2002-07-02 13:19 UTC] jan@php.net
Sorry, but the bug system is not the appropriate forum for asking
support questions. Your problem does not imply a bug in PHP itself.
For a list of more appropriate places to ask for help using PHP,
please visit http://www.php.net/support.php

Thank you for your interest in PHP.
 [2002-07-02 15:46 UTC] randy at careerstep dot com
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.
 [2002-07-02 15:48 UTC] randy at careerstep dot com
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.
 
PHP Copyright © 2001-2020 The PHP Group
All rights reserved.
Last updated: Thu Oct 22 13:01:24 2020 UTC