PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Moderator: General Moderators
farid
Forum Commoner
Posts: 54 Joined: Thu Nov 11, 2004 4:20 pm
Location: Mexico
Post
by farid » Thu May 19, 2005 1:33 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!!
shiznatix
DevNet Master
Posts: 2745 Joined: Tue Dec 28, 2004 5:57 pm
Location: Tallinn, Estonia
Contact:
Post
by shiznatix » Thu May 19, 2005 1:36 pm
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
farid
Forum Commoner
Posts: 54 Joined: Thu Nov 11, 2004 4:20 pm
Location: Mexico
Post
by farid » Thu May 19, 2005 1:40 pm
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);
shiznatix
DevNet Master
Posts: 2745 Joined: Tue Dec 28, 2004 5:57 pm
Location: Tallinn, Estonia
Contact:
Post
by shiznatix » Thu May 19, 2005 1:42 pm
after echo $some_var = explode(' ', $other_var);
do
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
farid
Forum Commoner
Posts: 54 Joined: Thu Nov 11, 2004 4:20 pm
Location: Mexico
Post
by farid » Thu May 19, 2005 1:47 pm
perfeeeeeect!! Cool man
Thanks ShizNatiX!!!
shiznatix
DevNet Master
Posts: 2745 Joined: Tue Dec 28, 2004 5:57 pm
Location: Tallinn, Estonia
Contact:
Post
by shiznatix » Thu May 19, 2005 1:50 pm
haha no problem man but it is shiznatix, no uppercase characers
. pronounced shiz nn A tix