• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 212
  • Last Modified:

PHP date formatting

Hi this is my PHP code.

$d=date("Ymd");
echo date("Y/m/d",$d);
output 1970/08/21
what i expect is m/d/Y
let me know how we do it in PHP, I am sure the solution can be applied to any date that has been created in PHP.
Regards,P.
0
gcmachel
Asked:
gcmachel
  • 2
1 Solution
 
Guy Hengel [angelIII / a3]Billing EngineerCommented:
$d=date("m/d/Y");
echo $d;

http://lu.php.net/datetime
0
 
Loganathan NatarajanLAMP DeveloperCommented:
best examples at http://in.php.net/date

0
 
gcmachelAuthor Commented:
Hi angelII,

Perfect that works, but i was not able to store the value inside mysql, mysql puts the value as 0000-00-00. so i want to create a date object with $d=date("Ymd"); and format $d.
Please let me know if its possible.

Regards,G.
0
 
gcmachelAuthor Commented:
I found the solution myself
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: Amazon Web Services - Basic

Are you thinking about creating an Amazon Web Services account for your business? Not sure where to start? In this course you’ll get an overview of the history of AWS and take a tour of their user interface.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now