Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- function xTimeAgo ($oldTime, $newTime, $timeType) {
- $timeCalc = strtotime($newTime) - strtotime($oldTime);
- if ($timeType == "x") {
- if ($timeCalc = 60) {
- $timeType = "m";
- }
- if ($timeCalc = (60*60)) {
- $timeType = "h";
- }
- if ($timeCalc = (60*60*24)) {
- $timeType = "d";
- }
- }
- //detik
- if ($timeType == "s") {
- $timeCalc .= $timeCalc;
- }
- //menit
- if ($timeType == "m") {
- $timeCalc = round($timeCalc/60);
- }
- //jam
- if ($timeType == "h") {
- $timeCalc = round($timeCalc/60/60);
- }
- //hari
- if ($timeType == "d") {
- $timeCalc = round($timeCalc/60/60/24);
- }
- return $timeCalc;
- }
- $sekarang=date("Y-m-d H:i:s");
- $dulu=date("Y-m-d")." 04:00:00";
- $durasi="2";
- $diff=xTimeAgo($sekarang,$dulu,"h");
- if($diff > $durasi)
- {
- echo "LEWAT";
- }else{
- echo "BELUM LEWAT";
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement