php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #33362 ftp_mdtm does not return correct date
Submitted: 2005-06-16 14:39 UTC Modified: 2005-06-16 19:41 UTC
From: till at klimpong dot com Assigned:
Status: Not a bug Package: FTP related
PHP Version: 4.3.10 OS: FreeBSD 5.2-current
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: till at klimpong dot com
New email:
PHP Version: OS:

 

 [2005-06-16 14:39 UTC] till at klimpong dot com
Description:
------------
ftp_mdtm always returns a wrong unix timestamp.

Our FTPd is proftpd (with TimesGMT off). The date, time and timezone are set correctly on the server.

When I connect to the FTP with another client (such as filezilla), all dates are displayed correct. This error only occurs within a PHP script.

For example:
current time on the server: 2:24PM
current time returned by ftp_mdtm: 4:24 PM

This example works:

<?php
echo strftime("%d.%m.%Y - %H:%M");
?>

Displays the correct time, so I guess this problem comes from ftp_mtdm().

Reproduce code:
---------------
<?php
$file = 'somefile.foo';
$ts = file_mtdm($file);
echo strftime("%d.%m.%Y - %H:%M", $ts);
?>


Expected result:
----------------
File's modification time.

Actual result:
--------------
The file's modification time plus two hours.

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-06-16 14:42 UTC] till at klimpong dot com
Forgot to add. I also set the locale on my system. Just to make sure that this is not some weird conversion bug.

<?php
setlocale(LC_ALL, 'de_DE.ISO8859-1');
?>
 [2005-06-16 18:10 UTC] sniper@php.net
Yes, because your time is GMT+2.

 [2005-06-16 18:19 UTC] till at klimpong dot com
Well, the server's time is set to GMT+2 already. The server is in my timezone and so on. So my local time and the server's time are the same.

If the server is GMT+2, then the function returns it with GMT+4. Where does the difference come from then?
 [2005-06-16 18:29 UTC] sniper@php.net
Check what MDTM command gives you for that file in question
using your ftp client:

> debug
> modtime yourfile

 [2005-06-16 18:46 UTC] till at klimpong dot com
Command:  MDTM apache-ssl.txt
Response: 213 20050616141816

Which is correct.

ftp_mdtm on the same file returns 11189314961
 [2005-06-16 18:55 UTC] sniper@php.net
You have extra '1' in the timestamp. (typo, I hope :)

# php -r 'echo gmdate("F d Y H:i:s", 1118931496);'
June 16 2005 14:18:16

That looks pretty okay to me.



 [2005-06-16 19:18 UTC] till at klimpong dot com
Typo indeed.

So I substituted strftime with gmdate and it works.

Thanks for your help.
 [2005-06-16 19:41 UTC] tony2001@php.net
It works -> no bug.
 [2013-09-09 16:14 UTC] daverandom@php.net
Automatic comment from SVN on behalf of daverandom
Revision: http://svn.php.net/viewvc/?view=revision&amp;revision=331330
Log: Clarify the mechanism of prepared statements in MySQLi quickstart

---
Provided by anonymous #33362 on PHDOE
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Thu Jul 03 11:01:34 2025 UTC