This is a function that helps to convert date to string.
$date = '24-04-2020' || Carbon Instance
1// ReadableDate ($date, string $timezone = null)2 3echo ReadableDate('24-04-2020');4// Return : 24 April 2020
1@ReadableDate('24-04-2020')
This is a function that helps to convert time to string.
$time = '15:20:22' || Carbon Instance
1// ReadableTime ($time, $is12Hours = false, bool $hasSeconds = false, string $timezone = null)2 3echo ReadableTime(Carbon::now());4// Return : 15:20
1@ReadableTime('15:20:21')
This is a function that helps to convert datetime to string.
$datetime = '24-04-2020 17:20:32' || Carbon Instance
1// ReadableDateTime ($datetime, $is12Hours = false, bool $hasSeconds = false, string $timezone = null)2 3echo ReadableDateTime(Carbon::now(), true, true);4// Return : Friday, April 24, 2020 05:20:32 PM
1@ReadableDateTime('24-04-2020 17:20:32', true, true)
This is a function that helps to find the difference between two datetime.
$oldDateTime = '24-04-2000 17:20:32' || Carbon Instance
$newDateTime = '24-04-2027 17:20:32' || Carbon Instance || null
1// ReadableDiffDateTime ($oldDateTime, $newDateTime = null, string $timezone = null)2 3echo ReadableDiffDateTime('24-04-2000 17:20:32', Carbon::now());4// Return : 27 years before
1@ReadableDiffDateTime('24-04-2000 17:20:32')
This is a function that helps to convert the seconds into full detailed time.
$oldDateTime = '24-04-2000 17:20:32' || Carbon Instance
$newDateTime = '24-04-2027 17:20:32' || Carbon Instance || null
1// ReadableTimeLength (int $seconds, string $comma = ' ', bool $short = false)2 3echo ReadableTimeLength(133955410);4// Return : 4 years 3 months 2 weeks 6 days 9 hours 50 minutes 10 seconds5// Comma => 4 years - 3 months - 2 week - 6 days - 9 hours - 50 minutes - 10 seconds6// Short => 4y 3m 2w 6d 9h 50m 10s
1@ReadableTimeLength(133955410)
This is a function that helps to find the difference between two datetime but with more options.
$oldDateTime = '24-04-2000 17:20:32' || Carbon Instance
$newDateTime = '24-04-2027 17:20:32' || Carbon Instance || null
1// ReadableDateTimeLength ($oldDateTime, $newDateTime = null, bool $fullForm = false, string $comma = ' ', string $timezone = null)2 3echo ReadableDateTimeLength('24-04-2020 17:20:32');4// Return : 27 years before
1@ReadableDateTimeLength('24-04-2000 17:20:32', '24-04-2027 17:20:32')