/ Published in: PHP
URL: http://reusablecode.blogspot.com/2009/02/difference-between-two-stardates.html
Calculates the difference between two Stardates and returns the result as a human-readable string.
Expand |
Embed | Plain Text
<?php /* Copyright (c) 2009, reusablecode.blogspot.com; some rights reserved. This work is licensed under the Creative Commons Attribution License. To view a copy of this license, visit http://creativecommons.org/licenses/by/3.0/ or send a letter to Creative Commons, 559 Nathan Abbott Way, Stanford, California 94305, USA. */ // Calculate the difference between two stardates. function stardatediff($firstStardate, $secondStardate) { if ($years1 > $years2) { $years = $years1 - $years2; } else { $years = $years2 - $years1; } if ($days1 > $days2) { $days = ($days1 * 366 / 1000) - ($days2 * 366 / 1000); } else { $days = ($days2 * 366 / 1000) - ($days1 * 366 / 1000); } if ($hours1 > $hours2) { $hours = ($hours1 * 144 / 60) - ($hours2 * 144 / 60); } else { $hours = ($hours2 * 144 / 60) - ($hours1 * 144 / 60); } return "There are $years years, $days days, and $hours hours between Stardate $firstStardate and Stardate $secondStardate."; } ?>
You need to login to post a comment.
