Solved

alter date format from 2013-08-11 14:23:14 to 11-08-2013 14:23

Posted on 2014-01-25
5
268 Views
Last Modified: 2014-01-25
hi

I have a database full of times in this format

year-month-day hour:minute:second

2013-08-11 14:23:14

When I show the on the page I want to re-write them using PHP to this format (UK), notice no seconds to display as well

day-month-year hour-minute

11-08-2013 14:23

full code please, not a page link
0
Comment
Question by:Neil Thompson
[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
5 Comments
 
LVL 110

Expert Comment

by:Ray Paseur
ID: 39808658
You need the page link to learn how this works, so here it is:
http://www.experts-exchange.com/Web_Development/Web_Languages-Standards/PHP/A_201-Handling-date-and-time-in-PHP-and-MySQL.html

Scan that page for Producing "Pretty" Dates From ISO-8601 Dates

I'll show you how to use PHP date() for this in a moment with a tested and working code sample.
0
 
LVL 110

Accepted Solution

by:
Ray Paseur earned 500 total points
ID: 39808660
See http://www.laprbass.com/RAY_temp_neilt.php

The pattern is on line 11.

<?php // RAY_temp_neilt.php
error_reporting(E_ALL);


// SEE http://www.experts-exchange.com/Web_Development/Web_Languages-Standards/PHP/Q_28348043.html
// REF http://www.php.net/manual/en/function.date.php

$old = '2013-08-11 14:23:14';
$new = '11-08-2013 14:23';

$get = date('d-m-Y H:i', strtotime($old));
if ($new == $get) echo 'SUCCESS!';

Open in new window

HTH, ~Ray
0
 
LVL 15

Expert Comment

by:Insoftservice
ID: 39808682
Try out this one

<html>
<head>
<title>PHP Script Execution</title>
</head>
<body>
<?php
   echo "<h1>Hello, PHP!</h1>";
   $date ="2013-08-11 14:23:14";
   echo "<br>".date("d-m-Y H:i",strtotime($date));
   
?>
</body>
</html>

Open in new window

0
 
LVL 3

Author Closing Comment

by:Neil Thompson
ID: 39809212
Many thanks Ray, Needed the code as I had to have a bit of work completed earlier today and its easier to grab it working first, then spend the time of an evening learning. (thanks to you I've done both)

Regards, Neil
0
 
LVL 110

Expert Comment

by:Ray Paseur
ID: 39809255
Glad to help, Neil.  Thanks for the points and thanks for using EE, ~Ray
0

Featured Post

[Live Webinar] The Cloud Skills Gap

As Cloud technologies come of age, business leaders grapple with the impact it has on their team's skills and the gap associated with the use of a cloud platform.

Join experts from 451 Research and Concerto Cloud Services on July 27th where we will examine fact and fiction.

Question has a verified solution.

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

There are times when I have encountered the need to decompress a response from a PHP request. This is how it's done, but you must have control of the request and you can set the Accept-Encoding header.
Originally, this post was published on Monitis Blog, you can check it here . In business circles, we sometimes hear that today is the “age of the customer.” And so it is. Thanks to the enormous advances over the past few years in consumer techno…
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…
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.

634 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