/ Published in: PHP
This is the Aidan Lister PHP countdown, translated for use in Norway.
No more 133 days untill christmas, but insted 3 months and 3 weeks.
No more 133 days untill christmas, but insted 3 months and 3 weeks.
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
<? $day = 21; // Day of the countdown $month = 12; // Month of the countdown $year = 2009; // Year of the countdown $hour = 23; // Hour of the day (east coast time) // s���¥ Aidans kode: /** * A function for making time periods readable * * @author Aidan Lister <[email protected]> * @version 2.0.0 * @link http://aidanlister.com/2004/04/making-time-periods-readable/ * @param int number of seconds elapsed * @param string which time periods to display * @param bool whether to show zero time periods */ function time_duration($seconds, $use = null, $zeros = false) { // Define time periods 'år' => 31556926, 'måneder' => 2629743, 'uker' => 604800, 'dager' => 86400, 'timer' => 3600, 'minutter' => 60, 'sekunder' => 1 ); // Break into periods $seconds = (float) $seconds; foreach ($periods as $period => $value) { continue; } if ($count == 0 && !$zeros) { continue; } $seconds = $seconds % $value; } // Build the string foreach ($segments as $key => $value) { if (($key == 'uker' && $value ==1)or($key == 'timer' && $value ==1)) { } elseif ($key == 'år') { $segment_name = $key; } else { } $segment = $value . ' ' . $segment_name; if ($value != 1) { // $segment .= 's'; $segment .= 'er'; } $array[] = $segment; } return $str; } ?> <?php echo time_duration($sekunder); // echo time_duration(100000000, null, true); // echo time_duration(100000000, 'yMw'); // echo time_duration(100000000, 'd'); ?> // Prints dates ala 3 m���¥neder, 3 uker, 19 timer, 1 minutt
URL: http://aidanlister.com/2004/04/making-time-periods-readable/