0

I have this date in my database 11/06/2013 12:00

This is my code and the format I would like it in

$dateformatstart = date_format(date_create($row['datestart']), 'D j M y H:i');

Although it comes back as

Wed 6 Nov 13 12:00

Think the month is the day and day is the month, I don't know why

Thanks

2
  • 1
    What would you like your date to look like? You didn't state that. Commented Jun 3, 2013 at 0:12
  • @TommyNaidich I need it in this format: D j M y H:i Commented Jun 3, 2013 at 0:21

2 Answers 2

2

Maybe this helps:

$date = DateTime::createFromFormat('d/m/Y H:i', $row['datestart']);

$dateformatstart = date_format($date, 'D j M y H:i');
Sign up to request clarification or add additional context in comments.

Comments

2

Have you even checked out the php manual before asking this question?

Well, Here are some clever ways on how to format dates in PHP

<?php
// Assuming today is March 10th, 2001, 5:16:18 pm, and that we are in the
// Mountain Standard Time (MST) Time Zone

$today = date("F j, Y, g:i a");                 // March 10, 2001, 5:16 pm
$today = date("m.d.y");                         // 03.10.01
$today = date("j, n, Y");                       // 10, 3, 2001
$today = date("Ymd");                           // 20010310
$today = date('h-i-s, j-m-y, it is w Day');     // 05-16-18, 10-03-01, 1631 1618 6 Satpm01
$today = date('\i\t \i\s \t\h\e jS \d\a\y.');   // it is the 10th day.
$today = date("D M j G:i:s T Y");               // Sat Mar 10 17:16:18 MST 2001
$today = date('H:m:s \m \i\s\ \m\o\n\t\h');     // 17:03:18 m is month
$today = date("H:i:s");                         // 17:16:18
$today = date("Y/m/d H:i");                   // 2001-03-10 17:16:18 (the MySQL DATETIME format)

If you are trying to output a data format like this :

11/06/2013 12:00

then better, Use

$today = date("d/m/Y H:i");

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.