Skip to content
/ grapes Public

PHP Grapes, A lightweight PHP package to manage date and time in PHP

License

Notifications You must be signed in to change notification settings

coswat/grapes

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

45 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

PHP Grapes

php grapes is a powerful and light weight package to play with time and date , easy to use

composer require coswat/grapes

usage

use Coswat\Grapes\Grape;

$time = 169268267; //unix timestamp

//returns 05:38:22
Grape::time($time)->toTime();

//returns 2023-02-27 05:39:09
Grape::time($time)->toRaw();

//returns 2023
Grape::time($time)->toYear();

//returns February
Grape::time($time)->toMonth();

//returns Sunday
Grape::time($time)->toDay();

//returns 5 minutes ago 
Grape::time($time)->timeAgo();

//returns nextday timestamp or unix
Grape::time($time)->nextDay();

//returns nextweek timestamp and unix
Grape::time($time)->nextWeek();

//returns nextmonth timestamp and unix
Grape::time($time)->nextMonth(); 

//returns timestamp of custom dates, for adding day
Grape::time($time)->addDays(3,true);

//returns timestamp of custom dates, for adding weeks
Grape::time($time)->addWeeks(1);

//returns timestamp of custom dates, for adding months
Grape::time($time)->addMonths(3);

Additional features

$ip = '8.8.8.8'; //ip address 

Grape::getTimezone($ip); // returns Asia/Kolkata

$start_time = microtime(true);

 // code to run 
 
$end_time = microtime(true);

Grape::getMs($start_time,$end_time); //returns 0.42 ms

whats new in latest version?

Grape::timeDiff(time(),1677625494);

/* will return time difference dynamically
(second,minutes,hours,days) */

Animated footer bars


Back to top

About

PHP Grapes, A lightweight PHP package to manage date and time in PHP

Topics

Resources

License

Stars

Watchers

Forks

Sponsor this project

 

Packages

No packages published

Languages