Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- // Truncate a string to the word closest to a certain number of characters
- preg_replace('/\s+?(\S+)?$/', '', substr($string, 0, $characters_number));
- ===============================================================================================
- //Compare Dates (only date, not time) :
- // actual day
- $d_now = new \DateTime('NOW');
- $d_otherDate = \DateTime::createFromFormat('Y-m-d', '2013-07-14');
- // do whatever with date, here add 3 months
- $d_otherDate->add(new \DateInterval('3PM'));
- // compares the date, here get the number of days between the 2 dates
- $s_diff = $d_otherDate->diff($d_now)->format("%a");
- if ($s_diff == '5') {
- // Do Stuff...
- }
- ===============================================================================================
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement