Jump to content


Need to figure out start time

  • Please log in to reply
3 replies to this topic

#1 SharkBait

  • Members
  • PipPipPip
  • Advanced Member
  • 845 posts
  • LocationMetro Vancouver, BC

Posted 21 June 2006 - 03:57 PM

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.

#2 Buyocat

  • Members
  • PipPipPip
  • Advanced Member
  • 267 posts

Posted 21 June 2006 - 04:03 PM

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]
Looking for some easy-to-use tools?  Try these, https://sourceforge....jects/utils-php -- I made them myself.  They're distinct tools which are easy to understand and use.  See some examples uses at http://www.anotherearlymorning.com

#3 .josh

  • Staff Alumni
  • .josh
  • 14,871 posts

Posted 21 June 2006 - 04:32 PM

wouldn't it be easier to just do like

$start = time();

//do code stuff here or whatever

$end = time();

$lengthoftime = $end - $start;

Did I help you? Feeling generous? Buy me lunch! 
Please, take the time and do some research and find out how much it would have cost you to get your help from a decent paid-for source. A "roll-of-the-dice" freelancer will charge you $5-$15/hr. A decent entry level freelancer will charge you around $15-30/hr. A professional will charge you anywhere from $50-$100/hr. An agency will charge anywhere from $100-$250/hr. Think about all this when soliciting for help here. Think about how much money you are making from the work you are asking for help on. No, we do not expect you to pay for the help given here, but donating a few bucks is a fraction of the cost of what you would have paid, shows your appreciation, helps motivate people to keep offering help without the pricetag, and helps make this a higher quality free-help community :)

#4 SharkBait

  • Members
  • PipPipPip
  • Advanced Member
  • 845 posts
  • LocationMetro Vancouver, BC

Posted 21 June 2006 - 04:49 PM

It would but I need it to set the start time at 6:45am everyday.

So this is what I ended up with:

$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);
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 :)

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users