Created
August 23, 2018 15:22
-
-
Save arosemena/502fb67ab2db1255031b05156821cab1 to your computer and use it in GitHub Desktop.
HTTP Middleware for Laravel
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 | |
namespace App\Http\Middleware; | |
use Illuminate\Foundation\Http\Middleware\TransformsRequest; | |
class FixDates extends TransformsRequest | |
{ | |
protected function transform($key, $value) | |
{ | |
// Transform the ISO 8601 from quasar components to a plain date | |
$match = "/^(-?(?:[1-9]\d*)?\d{4})-(1[0-2]|0[1-9])-(3[01]|0[1-9]|[12]\d)T(2[0-3]|[01]\d):([0-5]\d):([0-5]\d)(.\d+)?\-?(\d{2}):?(\d{2})/"; | |
return preg_match($match, $value) ? substr($value, 0, 10) : $value; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment