PHP code example of wazum / datetime-fractional-seconds

1. Go to this page and download the library: Download wazum/datetime-fractional-seconds library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

wazum / datetime-fractional-seconds example snippets


private const DATETIME_FORMAT = 'Y-m-d H:i:s.u';

public function __invoke(SomethingHappened $event): void 
{
    $occurredOn = \DateTimeImmutable::createFromFormat(
        self::DATETIME_FORMAT,
        $event->getOccurredOn()
    );
}