Solved

PHP date formatting

Posted on 2007-11-17
4
191 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 142

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 500 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

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Suggested Solutions

Introduction HTML checkboxes provide the perfect way for a web developer to receive client input when the client's options might be none, one or many.  But the PHP code for processing the checkboxes can be confusing at first.  What if a checkbox is…
Foreword (July, 2015) Since I first wrote this article, years ago, a great many more people have begun using the internet.  They are coming online from every part of the globe, learning, reading, shopping and spending money at an ever-increasing ra…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

744 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now