Last active
August 29, 2015 14:00
-
-
Save akritiko/11250683 to your computer and use it in GitHub Desktop.
Time travel (PHP)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Time Travel returns dates in the past or the future, to a specific format, based on a seed date. | |
* | |
* @param $date_format the format of dates (seed and returned) | |
* @param $date the seed date | |
* @param $where_to time travel "step" in days (e.g. for yesterday "-1", tomorrow "+1" and so forth) | |
*/ | |
function time_travel( $date_format, $date, $where_to ) { | |
return date( $date_format, strtotime( $date . ' ' . $where_to . ' day' ) ); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment