Solved

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

Posted on 2014-01-25
5
260 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:NeilT
  • 3
5 Comments
 
LVL 108

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 108

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:NeilT
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 108

Expert Comment

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

Featured Post

Highfive Gives IT Their Time Back

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

Both Easy and Powerful How easy is PHP? http://lmgtfy.com?q=how+easy+is+php (http://lmgtfy.com?q=how+easy+is+php)  Very easy.  It has been described as "a programming language even my grandmother can use." How powerful is PHP?  http://en.wikiped…
This article will explain how to display the first page of your Microsoft Word documents (e.g. .doc, .docx, etc...) as images in a web page programatically. I have scoured the web on a way to do this unsuccessfully. The goal is to produce something …
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

746 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

9 Experts available now in Live!

Get 1:1 Help Now