Skip to content

Instantly share code, notes, and snippets.

@rkcb
Last active September 1, 2018 20:17
Show Gist options
  • Select an option

  • Save rkcb/3c57c3795331833520a1f6aa540cc6e2 to your computer and use it in GitHub Desktop.

Select an option

Save rkcb/3c57c3795331833520a1f6aa540cc6e2 to your computer and use it in GitHub Desktop.
PHP date cheat sheet
$date = strtodate('-2 weeks', $unix_timestamp);
@rkcb
Copy link
Author

rkcb commented Aug 27, 2018

Time Argument Result
DateTime::createFromFormat('Y-m-d H:i:s', $date_str) DateTime
DateTime instance $date_datetime->getTimestamp()
Unix timestamp strtotime('+5 months', $unix_timestamp)
Unix timestamp date('Y-m-d H:i:s', $unix_timestamp)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment