mdate()

mdate([$datestr = ''[, $time = '']])

Parameters:
  • $datestr (string) – Date string
  • $time (int) – UNIX timestamp
Returns:

MySQL-formatted date

Return type:

string

This function is identical to PHP’s date() function, except that it lets you use MySQL style date codes, where each code letter is preceded with a percent sign, e.g. %Y %m %d

The benefit of doing dates this way is that you don’t have to worry about escaping any characters that are not date codes, as you would normally have to do with the date() function.

Example:

$datestring = 'Year: %Y Month: %m Day: %d - %h:%i %a';
$time = time();
echo mdate($datestring, $time);

If a timestamp is not included in the second parameter the current time will be used.

doc_CodeIgniter
2016-10-15 16:32:30
Comments
Leave a Comment

Please login to continue.