CodeIgniter: mysql format DATETIME field dd / mm / yy hh: mm

Hi, pretty much what he says in tin.

I have a mysql datetime field that I want to display in the format dd / mm / yyyy hh: mm like 07/01/2011 22:16.

I tried:

<?php 
  $datestring = '%d/%m/%Y %h:%i';  
  echo mdate($datestring,$row->created); 
?>

But I get an error message:

Message: A non well formed numeric value encountered

Any help is most appreciated!

Greetings

Billy

+3
source share
4 answers

Try:

echo date ("d/m/Y h:ia",strtotime($row->created));
+14
source

The second parameter to the function mdate()should still be an integer timestamp, just like the PHP built-in function date(). Try using a function strtodate()that takes a string as a parameter (including the MySQL date format) and returns an integer. This can be done as follows:

$datestring = '%d/%m/%Y %h:%i';
echo mdate($datestring, strtodate($row->created));

mdate() date() , CodeIgniter :

date() PHP, , MySQL, :% Y% m% d ..

, , - , , date().

+1

treeface :

$datestring = '%d/%m/%Y %h:%i';
echo mdate($datestring, strtoDATE($row->created)); 
    //strtoDATE didn't work but strtoTIME did

, , CI- .

0

:

mdate(date_string,mysql_to_unix($row->created))

.

-1

Source: https://habr.com/ru/post/1784186/


All Articles