# mktime problem...

- Thread: https://externals.io/message/7189
- Original archive: https://news-web.php.net/php.internals/7189
- Started by Jonathan Hernandez on 2004-01-19T19:20:58+00:00
- Messages: 3
- Reply by email to internals@lists.php.net
- More for agents: search with https://externals.io/search.md?q={query} · JSON API at https://externals.io/api · documentation at https://externals.io/llms.txt

---

## #7189 — Jonathan Hernandez — 2004-01-19T19:20:58+00:00

URL: https://externals.io/message/7189#7189

Hello,

I have a problem with mktime, when I try to run this:

<?php
$date = getdate(mktime(12, 0, 0, 1, 1 ,1959));
echo $date[0]."
".$date['mday']."-".$date['mon']."-".$date['year']."<br/>";
$date = getdate(-347090400);
echo $date[0]."
".$date['mday']."-".$date['mon']."-".$date['year']."<br/>";
?>

Output:
-62 31-12-1969
-347090400 1-1-1959

I compile php5.0b3 on Fedora(gcc 3.3.2/ kernel 2.4.22), if I try to run
it on Debian (gcc 2.95.4 / kernel 2.6.0) it works fine, 

Output:
-347090400 1-1-1959
-347090400 1-1-1959


Both php are compiled with the same ./configure line...


Any idea about this?



Thanks in advance,

Jonathan
http://ion.gluch.org.mx

---

## #7190 — Wez Furlong — 2004-01-19T20:05:29+00:00

URL: https://externals.io/message/7189#7190 · In reply to: #7189

Your libc doesn't support negative time_t values.

--Wez.

----- Original Message ----- 
From: "Jonathan Hernandez" <ion@gluch.org.mx>
To: <internals@lists.php.net>
Sent: Monday, January 19, 2004 7:20 PM
Subject: [PHP-DEV] mktime problem...


> Hello,
> 
> I have a problem with mktime, when I try to run this:
> 
> <?php
> $date = getdate(mktime(12, 0, 0, 1, 1 ,1959));
> echo $date[0]."
> ".$date['mday']."-".$date['mon']."-".$date['year']."<br/>";
> $date = getdate(-347090400);
> echo $date[0]."
> ".$date['mday']."-".$date['mon']."-".$date['year']."<br/>";
> ?>
> 
> Output:
> -62 31-12-1969
> -347090400 1-1-1959
> 
> I compile php5.0b3 on Fedora(gcc 3.3.2/ kernel 2.4.22), if I try to run
> it on Debian (gcc 2.95.4 / kernel 2.6.0) it works fine, 
> 
> Output:
> -347090400 1-1-1959
> -347090400 1-1-1959
> 
> 
> Both php are compiled with the same ./configure line...
> 
> 
> Any idea about this?

---

## #7194 — Jonathan Hernandez — 2004-01-19T23:51:04+00:00

URL: https://externals.io/message/7189#7194 · In reply to: #7190

Well, I see that is a normal behavior of libc/mktime (it returns -1 if
an error was detected), I see others have the same problem and
implements their own php/mktime function (see the first comment on
http://www.php.net/mktime)... I wonder if it can be implemented directly
on the php function...


> Your libc doesn't support negative time_t values.
> 
> --Wez.
> 
> ----- Original Message ----- 
> From: "Jonathan Hernandez" <ion@gluch.org.mx>
> To: <internals@lists.php.net>
> Sent: Monday, January 19, 2004 7:20 PM
> Subject: [PHP-DEV] mktime problem...
> 
> 
> > […]
