# Edit in JSFiddle

```function getTimeMoneyStart() {

// set the current date, hours, minutes, and seconds
var d = new Date();
var h = d.getHours();
var m = d.getMinutes();
var s = d.getSeconds();

// set the number of hours busy today
var busy = (\$(".busy_hours").val() != "") ? \$(".busy_hours").val() : 0;

// calculate the number of free hours today
var free = 24 - busy;

// calculate the number of free seconds today
var left = (free*60*60);

// convert the number of seconds left to currency!
var balance = "\$" + left.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");

\$(".balance_start").html("Today's starting balance: " + balance);
}

function getTimeMoneyNow() {

// set the current date, hours, minutes, and seconds
var d = new Date();
var h = d.getHours();
var m = d.getMinutes();
var s = d.getSeconds();

// set the number of hours busy today
var busy = (\$(".busy_hours").val() != "") ? \$(".busy_hours").val() : 0;

// calculate the number of free hours today
var free = 24 - busy;

// calculate the number of free seconds left today
var left = (free*60*60) - (h*60*60) - (m*60) - s;

// convert the number of seconds left to currency!
var balance = "\$" + left.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");

\$(".balance_now").html("Today's remaining balance: " + balance);
}

// on page load, show initial balance
getTimeMoneyStart();

// on page load, show balance as if all hours are free
getTimeMoneyNow(\$("input.busy_hours").val());

\$("input.busy_hours").keyup(function(){
getTimeMoneyStart();
getTimeMoneyNow();
});```
```* {
font-family: Arial, sans-serif;
}

h1 {
font-size: 1.3em;
text-decoration: underline;
}

p, input {
font-size: 1em;
}

p.busy span {
color: grey;
}

p.balance_now {
font-weight: 700;
}

input.busy_hours {
width: 2em;
text-align: center;
}

hr {
border: 0;
border-bottom: 1px solid #eee;
background: #eee;
}```
```<h1>Time Is Money Calculator</h1>
<p>Time is money, right? See how much "money" or free time you have left today.</p>

<p class="busy">Hours busy today:
<input class="busy_hours" value="0"/> <span>(e.g., 1, .5)</span>
</p>

<hr/>

<p class="balance_start"></p>
<p class="balance_now"></p>```