Gamenati
04-06-2003, 11:15 AM
Hey,
Anyone know why this isnt working?
the timestamp:
20030406004941
the function:
function date_str($timestamp) {
$date_str = getdate($timestamp) ;
$year = $date_str["year"] ;
$mon = $date_str["mon"] ;
$mday = $date_str["mday"] ;
$hours = $date_str["hours"] ;
$minutes = $date_str["minutes"] ;
$seconds = $date_str["seconds"] ;
return "$mon/$mday/$year" ;
}
the result:
1/18/2038
thanks in advance
digitok
04-06-2003, 11:41 AM
Whats the problem with it?
Gamenati
04-06-2003, 12:08 PM
as far as i know, yesterday was not 1/18/2038
cperciva
04-06-2003, 12:09 PM
You're obviously using a 32 bit version of PHP. A 64 bit version would correctly compute the date (April 15, 636708; 8:02:21 PM).
digitok
04-06-2003, 12:13 PM
It came out as 1/18/2038 on mine aswell.
Gamenati
04-06-2003, 12:24 PM
how can i get a 64 bit version?
cperciva
04-06-2003, 12:26 PM
Originally posted by Gamenati
how can i get a 64 bit version?
Why do you want to manipulate dates in the 637th millenium?
Gamenati
04-06-2003, 12:37 PM
20030406004941
this is a timestamp for YESTERDAY
cperciva
04-06-2003, 12:41 PM
No, it isn't. Yesterday would be something like 1049560830.
Gamenati
04-06-2003, 12:57 PM
wait, then MySQL is lying
Gamenati
04-06-2003, 01:03 PM
wait
20030406004941
2003 = year
04 = month
06 = day
00 = hour
49 = min
41 = seconds
cperciva
04-06-2003, 01:07 PM
Different programs store their timestamps in different formats.
digitok
04-06-2003, 01:26 PM
Did you get it to work? Mine shows up as that weird date to, I guess it's the format of the timestamp? :o
W-H-Mtl
04-06-2003, 02:57 PM
<?php
function date_string($timestamp) {
$date_str = getdate($timestamp);
$year = $date_str["year"] ;
$mon = $date_str["mon"] ;
$mday = $date_str["mday"] ;
$hours = $date_str["hours"] ;
$minutes = $date_str["minutes"] ;
$seconds = $date_str["seconds"] ;
return "$mon/$mday/$year" ;
}
?>
<?= date_string(1049560830); ?>
gave me: 4/5/2003
yet
<?= date_string(20030406004941); ?>
gave me:
Warning: Cannot perform date calculation in test.php on line 4
//
I conclude that your time stamp is what is causing your error.
Also, you may actually be running PHP in 64 bit mode, I
can't even get getdate to process your timestamp.
digitok
04-06-2003, 09:49 PM
how are you getting the timestamp from mysql?
did you try using UNIX_TIMESTAMP( ... ) around the part where you're getting the time from in the mysql query?
digitok
04-06-2003, 09:52 PM
Note for above... If you just want to use the current timestamp, you can use like UNIX_TIMESTAMP() but if you have a date stored in there you'd use UNIX_TIMESTAMP('1997-10-04 22:23:00') for example :)
Gamenati
04-07-2003, 12:58 PM
it says UNIX_TIMESTAMP() is undefined...
how could i make a current timestamp?
Gamenati
04-07-2003, 01:21 PM
nevermind, i just used time()
when i used that the function that i used also worked