mossengine / alteredcarbon
Carbon extended library with AltSO-8601 support
v1.2.0
2020-03-16 10:02 UTC
Requires
- php: >=5.4.0
- nesbot/carbon: 1.22.1 || ^2.28
- symfony/translation: ~2.6 || ~3.0 || ~4.0
Requires (Dev)
- friendsofphp/php-cs-fixer: ~2
- phpunit/phpunit: ~4.0 || ~5.0
This package is auto-updated.
Last update: 2024-11-16 20:30:44 UTC
README
This Library extends the Carbon\Carbon class to include extra support for other DateTime formats and in particular the AltSO8601 datetime format.
Functions
__constructor()
<?php $stringAltSO8601 = '20180215135543:Australia/Brisbane'; $alteredCarbon = new Mossengine\AlteredCarbon\AlteredCarbon($stringAltSO8601); $alteredCarbon->toDateTimeString(); // -> 2018-02-15 13:55:43 $alteredCarbon->getTimezone()->getName(); // -> Australia/Brisbane
createFromAltSO8601()
<?php $stringAltSO8601 = '20180215135543:Australia/Brisbane'; $alteredCarbon = Mossengine\AlteredCarbon\AlteredCarbon::createFromAltSO8601($stringAltSO8601); $alteredCarbon->toDateTimeString(); // -> 2018-02-15 13:55:43 $alteredCarbon->getTimezone()->getName(); // -> Australia/Brisbane
toAltSO8601String()
<?php $stringDateTime = '2018-02-15 13:55:43'; $stringTimeZone = 'Australia/Brisbane'; $alteredCarbon = new Mossengine\AlteredCarbon\AlteredCarbon($stringDateTime, $stringTimeZone); $alteredCarbon->toAltSO8601String(); // -> 20180215135543:Australia/Brisbane
Installation
With Composer
$ composer require mossengine/alteredcarbon
{ "require": { "mossengine/alteredcarbon": "~1.0.0" } }
<?php require 'vendor/autoload.php'; use Mossengine\AlteredCarbon\AlteredCarbon; printf("AltSO8601 Now: %s", AlteredCarbon::now()->toAltSO8601String());
Without Composer
Why are you not using composer? Download AlteredCarbon.php from the repo and save the file into your project path somewhere.
<?php require 'path/to/AlteredCarbon.php'; use Mossengine\AlteredCarbon\AlteredCarbon; printf("AltSO8601 Now: %s", AlteredCarbon::now()->toAltSO8601String());