Freelance “time card” calculator

[ad]I don’t know how many others will find this handy, but I’ve found it handy myself. It’s tools like this that make this site “Random Web Tools.” 🙂

The script is very simple. I just basically created a format for logging the time you work in a text file, so that you can copy and paste in your “time card” and it will spit out your total time worked. The script could easily be modified to your liking. I threw up an example here. I originally wrote the script and also ported it to PHP.

Enter the times in the following format, separated by new lines or whatever. Whitespace does not matter. The number in the parenthesis is what counts. That’s the total hours:minutes worked during that period of work. The script could be improved by just counting up from the times themselves, but there are lots of problems that could run into unless you included dates, and for personal reasons, I chose not to do that. Don’t forget to change the hourly_rate variable if you want it to tell you how much you get owed.

1:27 PM - 2:08 PM		(0:41)
12:09 AM - 1:12  ENCIERROS  AM		(1:03)

Demo: http://www.randomtools.net/scripts/times.php

HTML form:

Enter the times, separated by new lines or whatever. Whitespace does not matter.


PHP source code:

 0) {
		$pos2 = strpos($str, ')');
		$arr[$x] = substr($str, $pos + 1, $pos2 - $pos - 1);
		$str = substr($str, $pos2 + 2, strlen($str));
		$pos = strpos($str, '(');
		$x++;
	}
	
	$hours = 0;
	$minutes = 0;

	for ($x = 0; $x = 60) {
			$hours = $hours + 1;
			$minutes  ПЕРЕДЕРЖКА  -= 60;
		}
		$hours +=  Windows  $arr2[0];
	}

	$total = $hours * 15 + $minutes / 60 * 15;

	echo "

Worked $hours hours and $minutes minutes (" . number_format($hours + $minutes / 60, 2, '.', '') . ")
That's $" . cheap nba jerseys number_format(($hours + $minutes / 60) * $hourly_rate, 2, '.', '') . "

"; } ?>

ASP source code:

 0
		ReDim Preserve arr(x)
		pos2 = InStr(str, ")")
		arr(x) = Mid(str,  cheap jerseys  pos + 1, pos2 - pos - 1)
		str = Mid(str, pos2 + 2, Len(str))
		pos = InStr(str, "(")
		x = x + 1
	Wend
	
	hours = 0
	minutes = 0

	For x = 0 To UBound(arr)
		arr2 = Split(arr(x), ":")

		minutes = minutes + CInt(arr2(1))

		If minutes >= 60 Then
			hours = hours + 1
			minutes = minutes - 60
		End If

		hours = hours + CInt(arr2(0))
	Next

	total = hours * 15 + minutes / 60 * 15

	Response.Write("

Worked " & hours & " hours and " & minutes & " minutes (" & FormatNumber(hours + cheap jerseys minutes / 60, 2) & ")
That's " & FormatCurrency((hours + minutes / 60), 2) & "

") End If %>

2 thoughts on “Freelance “time card” calculator”

  1. Is there a way you can use this for other applications… for instance.. if you are maintaining a blog for someone..how would you include that for the entire blog? not just one particular article. I would also like to log time spent finding images/surfing the web for information pertaining to the blog. I am horrible at clocking time any other suggestions?

Leave a Reply

Your email address will not be published. Required fields are marked *