Skip to content

Instantly share code, notes, and snippets.

@lomotech
Created December 4, 2023 03:27
Show Gist options
  • Save lomotech/76eb2d2ecb7893e6cb526bbf09ec5dd3 to your computer and use it in GitHub Desktop.
Save lomotech/76eb2d2ecb7893e6cb526bbf09ec5dd3 to your computer and use it in GitHub Desktop.
Dapatkan tarikh hari ini jika bulan tersebut di panjangkan
<?php
use Carbon\Carbon;
$targetDate = '2023-08';
$today = Carbon::parse();
$target = Carbon::createFromFormat('Y-m', $targetDate)->endOfMonth();
$diff = $target->diffInDays($today);
echo 'Today: ' . $target->format('Y-m-') . ($target->format('d') + $diff); // at 2023-12-04 is 2023-08-125
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment