tags:

views:

20

answers:

3

I am attempting to store the date in a variable using getdate(). What am I doing wrong?

$today = getdate();

echo "the date today is ".$today;

Output: the date today is Array

A: 

getdate() returns an array. To echo seconds, you might want to try this:

$getdate = getdate();

echo "there are ".$getdate['seconds']." on the minute";

Check out all the keys and what they return here.

esqew
A: 

getdate() returns an array so you might want to do something like

echo 'The date today is '. $today['year'].'-'.$today['mon'].'-'.$today['mday'];

I would prefer using date():

echo 'The date today is '. date('Y-m-d');
MrSoundless
thanks this was just what i was looking for
tylercomp
A: 

That's because getdate() returns an array. Try

print_r($today)

to see for yourself. Also this should help you.

kirbuchi