?
Solved

PHP date time formating

Posted on 2011-02-25
6
Medium Priority
?
384 Views
Last Modified: 2012-05-11
How do I format date/time to 20110224T090000 format?
I looked up PHP date functions but most of the examples were for current date only.

Let's see I have a variable $start_date

The date that I have in Oracle database is: 4/14/2011 10:00:00 AM

How do I format this in PHP that it gives me 20110414T100000

Thanks much.
0
Comment
Question by:awarraic
  • 3
  • 3
6 Comments
 
LVL 24

Expert Comment

by:mankowitz
ID: 34979726
use date("Ymd\THis", $start_date)
0
 
LVL 24

Expert Comment

by:mankowitz
ID: 34979756
note that the date function assumes $start_date is in timestamp format. You can do that via oracle, or you can parse it with

echo date("Ymd\THis", strtotime($start_date));

0
 

Author Comment

by:awarraic
ID: 34979928
it shows some default date:
19700101T000003

Do I need to set some default date format or something?
Thanks.
0
Independent Software Vendors: 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!

 

Author Comment

by:awarraic
ID: 34979972
It worked, just missed strtotime(). thanks much.
0
 
LVL 24

Accepted Solution

by:
mankowitz earned 2000 total points
ID: 34980629
but i did answer.
0
 

Author Comment

by:awarraic
ID: 34981547
Sorry somehow the points thing didn't work.
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Build an array called $myWeek which will hold the array elements Today, Yesterday and then builds up the rest of the week by the name of the day going back 1 week.   (CODE) (CODE) Then you just need to pass your date to the function. If i…
Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
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…
Suggested Courses
Course of the Month13 days, 17 hours left to enroll

807 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