Ok so i have a script that use a date come from mysql db the prob is php look like to extract it weird...
The output should be 31.12.2002 but there IS ..2002
came from a script like this :
<?php
$date= "2002-12-31";
if (ereg ("([0-9]{4})-([0-9]{1,2})-([0-9]{1,2})", $date, $regs)) {
echo "$regs[3].$regs[2].$regs[1]";
} else {
echo "Invalid date format: $date";
}
?>
Whats the hell causing the date display ..2002 ?????
thanks for any help !
apokalyptik
08-22-2002, 09:59 PM
http://home.apokalyptik.com/~apokalyptik/tmp/
you can see a) that i'm running php 4.2.2 and b) that your script works as intended on my box
[19:01:07][apokalyptik@home:~/public_html/tmp]: ls -la
total 16
drwxr-xr-x 2 apokalyptik apokalyptik 4096 Aug 22 19:01 .
drwxr-xr-x 25 apokalyptik apokalyptik 4096 Aug 22 18:59 ..
-rw-r--r-- 1 apokalyptik apokalyptik 181 Aug 22 18:59 eregtime.php
lrwxrwxrwx 1 apokalyptik apokalyptik 12 Aug 22 19:01 eregtime.phps -> eregtime.php
-rw-r--r-- 1 apokalyptik apokalyptik 20 Aug 22 19:00 phpinfo.php
lrwxrwxrwx 1 apokalyptik apokalyptik 11 Aug 22 19:00 phpinfo.phps -> phpinfo.php
have you made sure of all the little simple things (e.g.: cleared your web browsers cach or your web proxies cache, etc?)
dreamrae.com
08-22-2002, 09:59 PM
too lazy to tell you, http://www.php.net/manual/en/function.date.php :stickout
The Prohacker
08-22-2002, 10:09 PM
UW PICO(tm) 4.2 File: test.php Modified
<?php
$date= "2002-12-31";
if (ereg ("([0-9]{4})-([0-9]{1,2})-([0-9]{1,2})", $date, $regs)) {
echo "$regs[3].$regs[2].$regs[1]";
} else {
echo "Invalid date format: $date";
}
?>
[ Wrote 11 lines ]
root@rum [~]# php test.php
X-Powered-By: PHP/4.2.2
Content-type: text/html
31.12.2002
root@rum [~]#
Works fine here...
I dont understand why its not working on my server .. :-(
There is some setting in PHP that can change that ???
what i can do to make that working ??
I'm realy lost ... :-(
Originally posted by apokalyptik
have you made sure of all the little simple things (e.g.: cleared your web browsers cach or your web proxies cache, etc?) [/B]
Yea, it look like the prob come from php itself or i dunno what..... I realy dont know where to search and what i can try to correct this ... :-(((
CagedTornado
08-23-2002, 01:42 AM
If your string contains a null (ASCII 0) character, ereg will not find any matches past it.
(Helpful?)
Dan
I use this little routine:
$stringArray = explode("-", $date);
$date2 = mktime(0,0,0,$stringArray[1],$stringArray[2],$stringArray[0]);
$zdate = date("d M Y", $date2);
Hopefully, that will work for you.
Lats...
Hi,
i have revert back my phplib.so to 4.1.1 then its working fine .... May be a compilation prob in my 4.2.2 ?
Someone have 4.2.2 installed can you send your .configure string you have used
i will try to recompiile it to see the result ... !