convert_date ()

function convert_date ($sql_date, $mode = '0', $days = 0)

Use this function to convert SQL formatted date (YYYY-MM-DD) $sql_date to human readable format.

$sql_date = the date to be converted. You can also use 'today' or 'now' to use today date.

$mode = can be:

  • 'short': to use short date format (defined in ACP > Configuration).
  • 'long': to use long date format (defined in ACP > Configuration).
  • 'mini': to use 'DD/MM' date format.
  • 'form': to use form date format (defined in ACP > Configuration).
  • 'sql': to use SQL formatted date (YYYY-MM-DD)
  • 'init' or 'unix': to return date in Unix timestamp.

$days = enter a number to see the date in the future or past $days.

If you set multiligual date in ACP > Configuration, this function will return the date in your local language (set in includes/lang.php file).

Example 1

require './includes/user_init.php';

// return current date, eg:
// Monday, August-23-2010
echo convert_date ('today', 'long');

// return 7 days ahead, eg:
// Aug-30-2010
echo convert_date ('today', 'short', 7);

Posted On: Aug-23-2010 @ 07:00am
Last Updated: Jan-01-1970 @ 07:00am

There is no comment. Why not be the first?

More Comments/Post Your Own

Online Users
There are 121 users online.

Connect with us on Facebook


Subscribe to our newsletter for the latest updates and exciting promotions!