PHP code example of neunerlei / tiny-timy

1. Go to this page and download the library: Download neunerlei/tiny-timy 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/ */

    

neunerlei / tiny-timy example snippets


use Neunerlei\TinyTimy\DateTimy;
$date = new DateTimy();
$date = new DateTimy("now");

use Neunerlei\TinyTimy\DateTimy;

// Set the client timezone
DateTimy::configureTimezone("Europe/London");
// Set the server timezone
DateTimy::configureTimezone("Europe/Moscow", true);

// New created instances ar now per default in the "Europe/Moscow" timezone
$i = new DateTimy();
$i->getTimezone()->getName(); // "Europe/Moscow"

// Convert it to the client timezone
$i->toClientTimezone()->getTimezone()->getName(); // "Europe/London"

// And back to the server timezone
$i->toServerTimezone()->getTimezone()->getName(); // "Europe/Moscow"

use Neunerlei\TinyTimy\DateTimy;
$date = new DateTimy(time() + 400);

use Neunerlei\TinyTimy\DateTimy;
$date = new DateTimy(new DateTimy());
$date = new DateTimy(new DateTime());

use Neunerlei\TinyTimy\DateTimy;
$date = new DateTimy("now", "Europe/Berlin");

use Neunerlei\TinyTimy\DateTimy;
$date = new DateTimy("2020.03.13 00:00", null, "Y.m.d H:i");

// You can use registered formats as well
$date = new DateTimy("2020.03.13 00:00", null, DateTimy::FORMAT_TYPE_DATE_AND_TIME);

use Neunerlei\TinyTimy\DateTimy;
$i = new DateTimy();
$i->format(DateTimy::FORMAT_TYPE_DATE);
// or
$i->formatDateAndTime();
// or
$i->format("dateAndTime");

use Neunerlei\TinyTimy\DateTimy;
// Editing an existing format
DateTimy::configureFormat(DateTimy::FORMAT_TYPE_DATE, "d.m.Y");
// Add your own format
DateTimy::configureFormat("specialFormat", "d-m-Y");

use Neunerlei\TinyTimy\DateTimy;
// Create from your special format
$i = new DateTimy("...", null, "specialFormat");
// Print your special format with
$i->formatSpecialFormat();
// or
$i->format("specialFormat");

use Neunerlei\TinyTimy\DateTimy;
// LOCALE de_DE.UTF8
$i = new DateTimy();
$i->formatLocalized("D"); // Montag