View Full Version : Obtaining characters
farid
05-19-2005, 07:19 PM
Hi y'all!!
Well Im trying to find a php function that can obtain certain number of characters from a date, that is, if I have the value :
2005-05-05 10:40:50.00
I must obtain only: 2005-05-05
Thanks!! :cool:
Velox Letum
05-19-2005, 07:23 PM
$mdate = '2005-05-05 10:40:50.00';
$mdate = date('Y-m-d', strtotime($mdate));
farid
05-19-2005, 07:28 PM
thanks velox!!!! :thumbsup:
farid
05-19-2005, 07:32 PM
oh oooh!! it appears this thing:
Warning: date(): Windows does not support dates prior to midnight (00:00:00), January 1, 1970 in D:\inetpub\InetGREGION9\php\fichas\test.php on line 50
marek_mar
05-19-2005, 08:30 PM
Switch to UNIX (or anything that supports negative timestamps)... or you could write a writearound for that but that requires lots of thinking which I'm not capable at the time :) .
EDIT: Oh I just read the title...
Tryed:
$date = substr($date, 0, 10);
Velox Letum
05-19-2005, 10:18 PM
While marek's solution would work just as effectively, I believe the problem with mine was your date had a decimal value and strtotime() threw a wobbly.
farid
05-19-2005, 11:37 PM
great !!! Thank you all!! :thumbsup:
vBulletin® v3.8.2, Copyright ©2000-2012, Jelsoft Enterprises Ltd.