Last active
May 17, 2018 16:18
-
-
Save asha23/93ff46a9b0430e2ee047246a696f8c38 to your computer and use it in GitHub Desktop.
Convert string to date - Then work out from today how many weeks until the date
This file contains hidden or 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
| // You won't need the string conversion if this is already a date object. | |
| $booking = '18/06/18'; // example string | |
| $date_array = implode('-', array_reverse(explode('/', $booking))); | |
| $now_booking = date('d/m/Y', strtotime($date_array)); | |
| $bookDate = DateTime::createFromFormat('d/m/Y', $now_booking); | |
| $waiting = $today->diff($bookDate); | |
| $interval = $waiting->format('%a') / 7; | |
| $weeks = number_format($interval, 1) + 0; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment