Jump to content

Archived

This topic is now archived and is closed to further replies.

SharkBait

Need to figure out start time

Recommended Posts

Trying to figure out the mktime of 6:45am of this day.

I'm doing: mktime(6,45);

Is that right?

What I will be doing is using that as my start time, then finding out what my current time is and substracting the two to see how much time has passed since.

Share this post


Link to post
Share on other sites
Looks good, you can double check here if you want a reference:
[a href=\"http://us3.php.net/mktime\" target=\"_blank\"]http://us3.php.net/mktime[/a]

Share this post


Link to post
Share on other sites
wouldn't it be easier to just do like

[code]
$start = time();

//do code stuff here or whatever

$end = time();

$lengthoftime = $end - $start;
[/code]

Share this post


Link to post
Share on other sites
It would but I need it to set the start time at 6:45am everyday.

So this is what I ended up with:
[code]
<?php

$TotalUnits = 0;
$sStart = mktime(06,45,0);
$sCurrent = mktime();

$betweenTime = substr(($sCurrent - $sStart) / 3600, 0, 3);

$startTime = date("Y-m-d 06:45:00");
$currentTime = date("Y-m-d h:m:s");

foreach($UNITS as $table => $name) {
  $strqry = "SELECT COUNT(*) as count FROM {$table} WHERE Real_Date = '{$startTime}' AND Real_Date <= '{$currentTime}'";
  $query = mysql_query($strqry) or die("MySQL Error: <br />{$strqry} <br /> ". mysql_error());
  $result = mysql_fetch_array($query, MYSQL_ASSOC);
  $TotalUnits = $TotalUnits + $result['count'];
}
echo substr($TotalUnits / $betweenTime, 0,2);
?>
[/code]
So now I can check between 6:45am and the current time, count the units that were entered and find the units per hour value :)

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.