unix_to_human()

unix_to_human([$time = ''[, $seconds = FALSE[, $fmt = 'us']]])

Parameters:
  • $time (int) – UNIX timestamp
  • $seconds (bool) – Whether to show seconds
  • $fmt (string) – format (us or euro)
Returns:

Formatted date

Return type:

string

Takes a UNIX timestamp as input and returns it in a human readable format with this prototype:

YYYY-MM-DD HH:MM:SS AM/PM

This can be useful if you need to display a date in a form field for submission.

The time can be formatted with or without seconds, and it can be set to European or US format. If only the timestamp is submitted it will return the time without seconds formatted for the U.S.

Examples:

$now = time();
echo unix_to_human($now); // U.S. time, no seconds
echo unix_to_human($now, TRUE, 'us'); // U.S. time with seconds
echo unix_to_human($now, TRUE, 'eu'); // Euro time with seconds
doc_CodeIgniter
2016-10-15 16:32:44
Comments
Leave a Comment

Please login to continue.