Last active
August 29, 2015 14:00
-
-
Save fedir/7fe0d3edb9a157009d6d to your computer and use it in GitHub Desktop.
php times
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
<?php | |
$now = time(); | |
$curMonth = date('n'); | |
$curYear = date('Y'); | |
if ($curMonth == 12) { | |
$currentMonthEnds = mktime(0, 0, 0, 1, 1, $curYear+1); | |
} else { | |
$currentMonthEnds = mktime(0, 0, 0, $curMonth+1, 1, $curYear); | |
} | |
echo date("Y-m-d H:i:s", $currentMonthEnds); |
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
<?php | |
$now = time(); | |
## Identifying current WE | |
// Next saturday begins | |
echo date( "Y-m-d H:i:s", strtotime( "next saturday" ) ); | |
// Next sunday ends | |
echo date( "Y-m-d H:i:s", strtotime( "next monday" ) ); | |
// Checking if the WE is already begins | |
if(strtotime( "next saturday" ) > strtotime( "next monday" ) ) { | |
// Or NO, it's already weekend | |
$weBegins = $now; | |
$weEnds = strtotime( "next monday" ); | |
} else { | |
$weBegins = strtotime( "next saturday" ); | |
$weEnds = strtotime( "next monday" ); | |
} |
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
<?php | |
$now = time(); | |
## Identifying current week | |
// Next sunday ends | |
echo date( "Y-m-d H:i:s", strtotime( "next monday" ) ); | |
// Checking if the WE is already begins | |
$weekBegins = $now; | |
$weekEnds = strtotime( "next monday" ); |
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
<?php | |
date_default_timezone_set("Europe/Paris"); | |
$now = time(); | |
$curMonth = date('n'); | |
$curYear = date('Y'); | |
if ($curMonth == 12) { | |
$currentMonthEnds = mktime(0, 0, 0, 1, 1, $curYear+1); | |
} else { | |
$currentMonthEnds = mktime(0, 0, 0, $curMonth+1, 1, $curYear); | |
} | |
echo date("Y-m-d H:i:s", $currentMonthEnds); | |
$nextMonthEnds = strtotime("+7 month first day midnight"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment