note 61667 deleted from function.date by derick
| From: | derick@php.net | Date: | Sun, 11 Jun 2006 11:43:07 +0000 |
| Subject: | note 61667 deleted from function.date by derick | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-114249@lists.php.net to get a copy of this message | ||
Note Submitter: kingofthew0rld at hotmail dot com
----
I can't use this on my site anymore because of problems with sotrting...
heres my function for seperating and seeing if a timestamp is rated by your limits minute count...
heres the class-timestamp.php:
<?PHP
class TIMESTAMP {
var $now_day;
var $now_time;
var $now_hour;
var $now_min;
var $now_sec;
var $now_whole;
var $then_day;
var $then_time;
var $then_hour;
var $then_min;
var $then_sec;
var $then_whole;
function splitStamps() {
list ($this->now_day, $this->now_time) = split("\ ", $this->now_whole);
list ($this->then_day, $this->then_time) = split("\ ", $this->then_whole);
list ($this->now_hour, $this->now_min,$this->now_sec) = split("\:",
$this->now_time);
list ($this->then_hour, $this->then_min,$this->then_sec) = split("\:",
$this->then_time);
return true;
}
function isRated($minutes) {
if ($this->now_day != $this->then_day) {
$hourDif = 23 - intval($this->then_hour);
$hourDif += intval($this->now_hour);
$allMin = (60 - $this->then_min) + ($hourDif * 60) + intval($this->now_min);
if ($allMin <= $minutes) { return true; }
return false;
}
$this->now_min = ($this->now_hour * 60) + ($this->now_min);
$this->then_min = ($this->then_hour * 60) + ($this->then_min);
$diff = ($this->now_min - $this->then_min);
if (intval($diff) <= intval($minutes)) {
return true;
}
return false;
}
}
?>
and heres how to run it
<?php
include ("php/class-timestamp.php");
$ts = new TIMESTAMP;
$ts->then_whole = "2006-02-08 00:00:00";
$ts->now_whole = date("Y-m-j H:i:s", time());
$ts->splitStamps();
if($ts->isRated("20")) {
echo "RATED!";
} else {
echo "NOT RATED!";
}
?>