Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Pb with the date.. please help

Status
Not open for further replies.

monasa

IS-IT--Management
Jun 27, 2004
41
0
0
CA
In the code bellow, when I show $dated I get 10-11-2004 but
When display $monthdeb, I get 2 !!


$dated = $row["dateD"];
echo $dated; //10-11-2004
//recuperer $datedeb de la base de donnée

$monthdeb = $datedeb["mon"];
echo $monthdeb //2

Please help
 
I m sorry, the code is "

$dated = $row["dateD"]; //get a date from database
echo $dated; //10-11-2004

$monthdeb = $dated["mon"];
echo $monthdeb //I get 2!!

Thanks in advance

 
The question still stands.

$dated will be one element from $row, specifically $row['dateD']. If $row is a row from a database it will be a singleton, not an array. Yet you are trying to reference an element of this singleton.


Want the best answers? Ask the best questions!

TANSTAAFL!!
 

The probleme which I have is :
I have a date field in the mysql database, and I want to get the month from this field with php.

for example if the date in the database is 10-11-2004, I want to have 11 as the month

thanks.
 
You can't just try to reference a month element. You're dealing with a string, not some kind of object.

You have several options. One is to use substr() to typographically pull out what you need. Another is to have Mysql separate out the date parts using its builtin date_format() function. A third would be to use PHP's strtotime() and getdate() functions to split the date up into parts.


Want the best answers? Ask the best questions!

TANSTAAFL!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top