Answers for "carbon formats"

PHP
5

carbon now format

use Carbon/Carbon
Carbon::now()->format('Y-m-d H:i:s');
Posted by: Guest on August-19-2020
9

carbon date from format

Carbon::createFromFormat('Y-m-d H:i:s', $request->date)->format('d-m-Y')
Posted by: Guest on April-26-2020
2

php carbon get timestamp

Carbon::now()->timestamp
Posted by: Guest on April-01-2020
4

carbon format date in laravel

1. First parse the created_at field as Carbon object.
	$createdAt = Carbon::parse($item['created_at']);

2.Then you can use
	$suborder['payment_date'] = $createdAt->format('M d Y');
Posted by: Guest on August-08-2020
0

Carbon Formatting Carbon Format

$dt = Carbon::create(1975, 12, 25, 14, 15, 16);

var_dump($dt->toDateTimeString() == $dt);          // bool(true) => uses __toString()
echo $dt->toDateString();                          // 1975-12-25
echo $dt->toFormattedDateString();                 // Dec 25, 1975
echo $dt->toTimeString();                          // 14:15:16
echo $dt->toDateTimeString();                      // 1975-12-25 14:15:16
echo $dt->toDayDateTimeString();                   // Thu, Dec 25, 1975 2:15 PM

// ... of course format() is still available
echo $dt->format('l jS \\of F Y h:i:s A');         // Thursday 25th of December 1975 02:15:16 PM

// The reverse hasFormat method allows you to test if a string looks like a given format
var_dump(Carbon::hasFormat('Thursday 25th December 1975 02:15:16 PM', 'l jS F Y h:i:s A')); // bool(true)
Posted by: Guest on June-22-2021

Browse Popular Code Answers by Language