PHP code example of wapmorgan / time-parser

1. Go to this page and download the library: Download wapmorgan/time-parser 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/ */

    

wapmorgan / time-parser example snippets


    $parser = new wapmorgan\TimeParser\TimeParser('all');
    

    // To enable alphabetic parsing.
    $parser->allowAlphabeticUnits();
    // To disable alphabetic parsing.
    $parser->disallowAlphabeticUnits();
    

    $datetime = $parser->parse(fgets(STDIN));
    // next call returns false
    $datetime = $parser->parse('abc', true);
    // $result will contains "we will come "
    $datetime = $parser->parse('We will come in a week', true, $result);
    

    // $date must be an array with a structure like the existing rules.
    $parser->addLanguage($data);
    

TimeParser::enableDebug();
// and
TimeParser::disableDebug();