Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- getRestTime();
- function getRestTime(){
- $TimePlay = getTime();
- $day = $TimePlay[0];
- $hour = $TimePlay[1];
- $minute = $TimePlay[2];
- $second = $TimePlay[3];
- $sumTimePlay = $day*24*60*60 + $hour*60*60 + $minute*60 + $second;
- $week = 7*24*60*60;
- $sumRestTime = $week - $sumTimePlay;
- $mod = $sumRestTime % (24*60*60);
- $day = ($sumRestTime - $mod) / (24*60*60);
- $rest_time = $sumRestTime - $day * 24*60*60;
- $mod = $rest_time % (60*60);
- $hour = ($rest_time - $mod) / (60*60);
- $rest_time = $rest_time - $hour * 60*60;
- $mod = $rest_time % 60;
- $minute = ($rest_time - $mod) / 60;
- $second = $rest_time - $minute * 60;
- /*
- $original_time_string = "2015-09-20 00:00:00";
- $original_time = convert_datetime($original_time_string);
- $now = time();
- echo "<br>--------------<br>";
- echo $original_time_string;
- echo "<br>";
- echo date('Y-m-d H:i:s', $now);
- echo "<br>";
- echo $day . " " . $hour . " " . $minute . " " . $second;
- */
- return array ($day, $hour, $minute, $second);
- }
- function getTime(){
- $original_time_string = "2015-09-20 00:00:00";
- $original_time = convert_datetime($original_time_string);
- $now = time();
- $rest_time = $now - $original_time;
- $mod = $rest_time % (24*60*60);
- $day = ($rest_time - $mod) / (24*60*60);
- $day2 = $day % 7;
- $rest_time = $rest_time - $day * 24*60*60;
- $mod = $rest_time % (60*60);
- $hour = ($rest_time - $mod) / (60*60);
- $rest_time = $rest_time - $hour * 60*60;
- $mod = $rest_time % 60;
- $minute = ($rest_time - $mod) / 60;
- $second = $rest_time - $minute * 60;
- /*
- echo $original_time_string;
- echo "<br>";
- echo date('Y-m-d H:i:s', $now);
- echo "<br>";
- echo $day2 . " " . $hour . " " . $minute . " " . $second;
- */
- return array ($day2, $hour, $minute, $second);
- }
- function convert_datetime($str) {
- list($date, $time) = explode(' ', $str);
- list($year, $month, $day) = explode('-', $date);
- list($hour, $minute, $second) = explode(':', $time);
- $timestamp = mktime($hour, $minute, $second, $month, $day, $year);
- return $timestamp;
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment