?
Solved

PHP date formatting

Posted on 2007-11-17
4
Medium Priority
?
207 Views
Last Modified: 2010-04-21
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
Comment
Question by:gcmachel
  • 2
4 Comments
 
LVL 143

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 1000 total points
ID: 20304709
$d=date("m/d/Y");
echo $d;

http://lu.php.net/datetime
0
 
LVL 36

Expert Comment

by:Loganathan Natarajan
ID: 20304747
best examples at http://in.php.net/date

0
 
LVL 4

Author Comment

by:gcmachel
ID: 20305853
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
 
LVL 4

Author Closing Comment

by:gcmachel
ID: 31409729
I found the solution myself
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
There are times when I have encountered the need to decompress a response from a PHP request. This is how it's done, but you must have control of the request and you can set the Accept-Encoding header.
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
Suggested Courses
Course of the Month16 days, 5 hours left to enroll

850 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question