PHP code example of jono20201 / input-to-date

1. Go to this page and download the library: Download jono20201/input-to-date 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/ */

    

jono20201 / input-to-date example snippets


    $user_input = '01/01/2016 09:30:30'
    $date = InputToDate::create('d/m/Y H:i:s')
                        ->convert($user_input);

    $user_input = '01/01/2016 09:30:30'
    $date = InputToDate::create('d/m/Y')
                        ->setReturnNullOnFailure()
                        ->convert($user_input);

    $user_input = '01/01/2016 09:30:30'
    $date = InputToDate::create('d/m/Y')
                        ->setDefault(Carbon::now())
                        ->convert($user_input);

    $user_input = '01/01/2016 09:30:30'
    $date = InputToDate::create('d/m/Y')
                        ->convert($user_input);