Created
October 19, 2020 20:00
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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