Skip to content

Instantly share code, notes, and snippets.

@Joncom
Created December 18, 2017 15:58
Show Gist options
  • Save Joncom/93fb0c8db6eb813a816f08bbb1a35381 to your computer and use it in GitHub Desktop.
Save Joncom/93fb0c8db6eb813a816f08bbb1a35381 to your computer and use it in GitHub Desktop.
Converting to and from UTC and Unix time
<?php
// Convert UTC time string to Unix time interger.
$timestamp = strtotime ( '2014-12-29 12:30:21+0000' );
// Convert Unix time integer back to UTC time string.
echo gmdate(DateTime::ISO8601, $timestamp);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment