Solved

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

Posted on 2014-01-25
5
267 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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering 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

Title # Comments Views Activity
can i read my emails on lamp ftp 4 70
php output utf-8 problem 6 51
Help installing Laravel app on MAMP on MAC 7 56
replacate wordpress websites 3 23
Things That Drive Us Nuts Have you noticed the use of the reCaptcha feature at EE and other web sites?  It wants you to read and retype something that looks like this. Insanity!  It's not EE's fault - that's just the way reCaptcha works.  But it i…
Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
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.

734 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