?
Solved

Convert a String To DateTime Format

Posted on 2007-10-06
4
Medium Priority
?
15,108 Views
Last Modified: 2012-05-05
Hi experts,

I have a problem with datetime format in PHP

Example :  I have a string :  "2007-10-06 20:45:00" (a datetime string) , and How to that string convert to "20:45 06-10" ?

Thanks & Regards
TrungGN
0
Comment
Question by:trung85gn
  • 2
4 Comments
 
LVL 11

Accepted Solution

by:
MacAnthony earned 375 total points
ID: 20027900
Try:

<?

print date('H:i d-m', strtotime('2007-10-06 20:45:00'));

?>

If you want to change the format, you can find the codes here: http://www.php.net/manual/en/function.date.php
0
 
LVL 16

Expert Comment

by:Kiran Paul VJ
ID: 20028026
0
 
LVL 11

Expert Comment

by:MacAnthony
ID: 20028031
If you use mktime, you will need to parse the original time format. IMO, it's easier to let strtotime parse it.
0
 

Author Comment

by:trung85gn
ID: 20028133
Thanks & Regards

TrungGN
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

3 proven steps to speed up Magento powered sites. The article focus is on optimizing time to first byte (TTFB), full page caching and configuring server for optimal performance.
This article discusses how to implement server side field validation and display customized error messages to the client.
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 dynamically set the form action using jQuery.
Suggested Courses
Course of the Month17 days, 11 hours left to enroll

830 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