Solved

PHP date time formating

Posted on 2011-02-25
6
334 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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 

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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Consider the following scenario: You are working on a website and make something great - something that lets the server work with information submitted by your users. This could be anything, from a simple guestbook to a e-Money solution. But what…
This article discusses four methods for overlaying images in a container on a web page
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…
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…

705 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

19 Experts available now in Live!

Get 1:1 Help Now