Page 1 of 1

Obtaining certain characters

Posted: Thu May 19, 2005 1:33 pm
by farid
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!! :roll:

Posted: Thu May 19, 2005 1:36 pm
by shiznatix
if thats the situation do

Code: Select all

$other_var = '2005-05-05 10:40:50.00';
$some_var = explode(' ', $other_var);
//$some_var[0] will = 2005-05-05

Posted: Thu May 19, 2005 1:40 pm
by farid
jus“a thing, it appears this:

2005-05-05 10:40:50.00
Array

with

Code: Select all

echo $other_var = '2005-05-05 10:40:50.00', "<br>";
echo $some_var = explode(' ', $other_var);

Posted: Thu May 19, 2005 1:42 pm
by shiznatix
after echo $some_var = explode(' ', $other_var);

do

Code: Select all

print_r($some_var);
its a array so you cant just echo it out, if you echo it out you have to give it a certain key to echo out such as $some_var[0] 0 being the key and the brackets holding the key to the array. since your just echoing out $some_var you just see array because thats what $some_var is without a specified key

Posted: Thu May 19, 2005 1:47 pm
by farid
perfeeeeeect!! Cool man 8) Thanks ShizNatiX!!!

Posted: Thu May 19, 2005 1:50 pm
by shiznatix
haha no problem man but it is shiznatix, no uppercase characers :D . pronounced shiz nn A tix