PHP code example of grosv / sundial
1. Go to this page and download the library: Download grosv/sundial 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/ */
grosv / sundial example snippets
$parser = new Grosv\Sundial\Parser();
$parser->parse('9th of August 2024 at 11:30 am')->toTimestamp(); // Get a unix timestamp
$parser->parse('December the 25th of this year')->toFormat('m/d/Y'); // 12/25/2020
// You can set a valid date range with setBetween($start, $end) where start and end are UNIX timestamps.
$parser->setBetween(time(), strtotime('+1 year'))->parse('tomorrow')->toFormat('m/d/Y'); // Works as expected
$parser->setBetween(time(), strtotime('+1 year'))->parse('August 9, 1992')->toFormat('m/d/Y'); // Exception
// By default we use English but this can be overridden using the ISO 639-2 Code of the language if we have it.
$parser->setLanguage('esp')->parse('23 Mayo, 20204')->toFormat('m/d/Y'); // 05/23/2024