Skip to content

PHP Converter between Star Trek's stardates and real date/time expressions.

License

Notifications You must be signed in to change notification settings

etienneq/stardate-calculator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Stardate Calculator

PHP Converter between Star Trek's stardates and real date/time expressions.

At the moment only TNG-era stardates are supported.

Prerequisites

Stardate Calculator requires PHP >= 7.2.

Installation

Use Composer to install this package:

composer require etienneq/stardate-calculator

Usage

Calculate real-world dates from stardates

$calculator = new \EtienneQ\Stardate\Calculator();

// outputs 2373-11-23 03:03:36
echo $calculator->toGregorianDate(50893.5)->format('Y-m-d H:i:s');

toGregorianDate() returns a \DateTime object which allows you to format the date/time expression as you like.

Calculate stardates from real-world dates

$calculator = new \EtienneQ\Stardate\Calculator();

// outputs 41001.76
echo $calculator->toStardate(new \DateTime('2364-01-01 15:30:00'));

toStardate() has a second parameter which allows you to change decimal precision (defaults to 2).

$calculator = new \EtienneQ\Stardate\Calculator();

// outputs 41001.76457
echo $calculator->toStardate(new \DateTime('2364-01-01 15:30:00'), 5);

About

PHP Converter between Star Trek's stardates and real date/time expressions.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published