Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- function dateNext($dayName)
- {
- $timeVar = time();
- while($dayName != date("D", $timeVar) && $timeVar - time() <= 604800) // Run this loop untill we find the next day with the given weekname, or untill we've looked more than a week ahead (something went wrong)
- {
- $timeVar += 86400 // Add a day
- }
- if($timeVar - time() > 604800) // If we looped past what would be a week, return -1
- {
- return -1;
- }
- $seconds_since_morning = (int)date("s", $timeVar) + (int)date("i", $timeVar); * 60 + (int)date("G", $timeVar) * 60 * 60; // Use the date function to get the time in hours minutes and seconds, and convert to seconds
- return $timeVar - $seconds_since_morning; // Return the Unix timestamp for 00:00:00 on the next occurance of the date
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement