Skip to content

Instantly share code, notes, and snippets.

@ianhawes
Created October 19, 2020 20:00
Show Gist options
  • Save ianhawes/6257da08da0c98661a551cb29f9b483a to your computer and use it in GitHub Desktop.
Save ianhawes/6257da08da0c98661a551cb29f9b483a to your computer and use it in GitHub Desktop.
This helper function converts the stringified PDF metadata timestamp into a readable timestamp
<?php
use Carbon\Carbon;
/**
* Converts a PDF metadata timestamp (creation_date, mod_date, etc..) into a Carbon object.
*
* @ref http://www.verypdf.com/pdfinfoeditor/pdf-date-format.htm
* @param $pdf_date
* @return Carbon
*/
function pdf_date_to_carbon($pdf_date) {
$pdf_date = str_replace('\'','',str_replace('D:','',$pdf_date));
return Carbon::createFromFormat('YmdHisO',
substr($pdf_date,0,19));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment