Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /* - (string) tos_stardate
- *
- * Random 4-numbers (progressively higher throughout an episode), followed by a single decimal place representing time of day.
- */
- function tos_stardate($timestamp = NULL) {
- if(!$timestamp) $timestamp = time();
- $hour = date('G', $timestamp);
- $percent = intval($hour) / 24;
- return mt_rand(1000,9999) . '.' . round($percent * 10);
- }
- /* - (string) tng_stardate
- *
- * Century number - 20 followed by season number of show, followed by 3 random numbers (in progression throughout an episode),
- * followed by a decimal and day of year.
- */
- function tng_stardate($season = 1, $timestamp = NULL) {
- if(!$timestamp) $timestamp = time();
- $century = intval(substr(date('Y', $timestamp), 0, 2)) + 1;
- $century = $century - 20;
- return $century . $season . mt_rand(000, 999) . '.' . date('z', $timestamp);
- }
- /* - (string) new_stardate
- *
- * Easy: year, decimal, day-of-year
- */
- function new_stardate($timestamp = NULL) {
- if(!$timestamp) $timestamp = time();
- return date('Y.z', $timestamp);
- }
- echo 'The Original Series: ' . tos_stardate() . '<br />'
- . 'The Next Generation: ' . tng_stardate(4) . '<br />'
- . 'New Star Trek: ' . new_stardate();
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement