Skip to content

Instantly share code, notes, and snippets.

@aldhinya
Created January 7, 2023 08:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aldhinya/3ee2612eb37ff7c98311dd5a99f55250 to your computer and use it in GitHub Desktop.
Save aldhinya/3ee2612eb37ff7c98311dd5a99f55250 to your computer and use it in GitHub Desktop.
$tanggal = $this->transformDate($i[2])->toDateString();
public function transformDate($value, $format = 'Y-m-d')
{
try {
return \Carbon\Carbon::instance(\PhpOffice\PhpSpreadsheet\Shared\Date::excelToDateTimeObject($value));
} catch (\ErrorException $e) {
return \Carbon\Carbon::createFromFormat($format, $value);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment