Calculate total hours in PHP

Description

The following code shows how to calculate total hours.

Example


<?php//w w w.  j  av  a2s . c o  m

$now = mktime();
$taxday = mktime(0,0,0,4,15,2010);

// Difference in seconds
$difference = $taxday - $now;

// Calculate total hours
$hours = round($difference / 60 / 60);

echo "Only $hours hours until tax day!";

?>

The code above generates the following result.





















Home »
  PHP Tutorial »
    Data Types »




Array
Array Associative
Array Util
ArrayObject
Data Types
Date
Date Format
DateTime
Number
String
String Escape
String Filter
String HTML
String Type
Timezone