Solved

PHP date time formating

Posted on 2011-02-25
6
369 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 500 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: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone 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

Suggested Solutions

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…
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…
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…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

696 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