Skip to content

Instantly share code, notes, and snippets.

@fer-ri
Last active August 29, 2015 14:00
Show Gist options
  • Select an option

  • Save fer-ri/11407986 to your computer and use it in GitHub Desktop.

Select an option

Save fer-ri/11407986 to your computer and use it in GitHub Desktop.
Postgresql Age Function With PHP
<?php
// ref : http://www.php.net/manual/en/datetime.diff.php
// ref : http://www.php.net/manual/en/dateinterval.format.php
$datetime1 = date_create('2009-10-11');
$datetime2 = date_create('2009-10-13');
$interval = date_diff($datetime1, $datetime2);
echo $interval->format('%y years %m months %d days');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment