2
0

git.class.php 370 B

1234567891011121314
  1. <?php
  2. class git
  3. {
  4. public static function getVersion()
  5. {
  6. $commitHash = trim(exec('git log --pretty="%h" -n1 HEAD'));
  7. $commitDate = new \DateTime(trim(exec('git log -n1 --pretty=%ci HEAD')));
  8. $commitDate->setTimezone(new \DateTimeZone('UTC'));
  9. return sprintf('%s (%s)', $commitHash, $commitDate->format('Y-m-d H:i:s'));
  10. }
  11. }