note 61667 added to function.date
| From: | kingofthew0rld at hotmail dot com | Date: | Wed, 08 Feb 2006 21:09:00 +0000 |
| Subject: | note 61667 added to function.date | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-103338@lists.php.net to get a copy of this message | ||
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!";
}
?>
----
Server IP: 64.71.164.2
Probable Submitter: 24.7.129.193
----
Manual Page -- http://www.php.net/manual/en/function.date.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+61667
Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+61667&report=yes&reason=added+to+the+manual
Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+61667&report=yes&reason=bad+code
Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+61667&report=yes&reason=spam
Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+61667&report=yes&reason=useless
Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+61667&report=yes&reason=non-english
Delete: already in docs -- http://master.php.net/manage/user-notes.php?action=delete+61667&report=yes&reason=already+in+docs
Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+61667&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+61667&report=yes
Search -- http://master.php.net/manage/user-notes.php