KoolReport's Forum

Official Support Area, Q&As, Discussions, Suggestions and Bug reports.
Forum's Guidelines

How to set default date to yesterday and today for RateRangePicker #2953

Open AhmedHaroon opened this topic on on Jan 19, 2023 - 3 comments

AhmedHaroon commented on Jan 19, 2023

i want to set default dates for RateRangePicker from yesterday to today, below is my code to have it but when set $yday as below it is showing "1969-12-31" and for $today it is showing correct date of today. please guide how i can set correct yesterday's date as "2023-01-18".

protected function defaultParamValues()
    {
        $today = date("Y-m-d");
        $yday = date("Y-m-d", -1);
        return array(
            // "dateRange"=>array(date("2022-12-01"),date("2022-12-01")),
            "dateRange"=>array($yday,$today),
            "customers"=>NULL,
        );
    }

.view.php

            DateRangePicker::create(array(
                            "name"=>"dateRange",
                            "format"=>"YYYY-MM-DD",
                            "timeZone" => "ZZ"
                        ))

regards

KoolReport commented on Jan 19, 2023

Let try:

$yday = date("Y-m-d", time() - 60 * 60 * 24);
AhmedHaroon commented on Jan 20, 2023

thanks @KoolReprt

will try it and confirm.

AhmedHaroon commented on Jan 23, 2023

@KoolReport thanks for help. it works fine, screenshot at below:

regards

Build Your Excellent Data Report

Let KoolReport help you to make great reports. It's free & open-source released under MIT license.

Download KoolReport View demo
help needed

None