Answers for "php get yesterday date"

PHP
6

yesterday php

date('F j, Y',strtotime("-1 days"));
Posted by: Guest on December-10-2020
1

php yesterday

$yesterday = new DateTime('yesterday');
echo $yesterday->format('Y-m-d');
Posted by: Guest on December-21-2020
1

php strtotime 1 day ago from

date('Y-m-d', strtotime('+1 day', strtotime($date)))
Posted by: Guest on July-13-2020
1

yesterday php

date("F j, Y", time() - 86400);
Posted by: Guest on December-10-2020
0

check if given date time is of today or yesterday php

function getRangeDateString($timestamp) {
    if ($timestamp) {
        $currentTime=strtotime('today');
        // Reset time to 00:00:00
        $timestamp=strtotime(date('Y-m-d 00:00:00',$timestamp));
        $days=round(($timestamp-$currentTime)/86400);
        switch($days) {
            case '0';
                return 'Today';
                break;
            case '-1';
                return 'Yesterday';
                break;
            case '-2';
                return 'Day before yesterday';
                break;
            case '1';
                return 'Tomorrow';
                break;
            case '2';
                return 'Day after tomorrow';
                break;
            default:
                if ($days > 0) {
                    return 'In '.$days.' days';
                } else {
                    return ($days*-1).' days ago';
                }
                break;
        }
    }
}
Posted by: Guest on September-16-2021

Browse Popular Code Answers by Language