I am using strtotime to convert date into time stamp but its does not work correctly. I know its relatively to time zone. My drupal store time zone is denver. I am not sure why its not showing correct date. there is around one day difference. so The last date I used 31 but I get last date of 30th not 31
Here are my query to make date into time and fetch record
date_default_timezone_set(drupal_get_user_timezone());
$startdate = strtotime(\Drupal::request()->query->get('startdate')); // 2021-12-01
$endate = strtotime(\Drupal::request()->query->get('enddate')); //2021-12-31
$database = \Drupal::database();
if(!empty($startdate)){
$userrecord = $database->query("SELECT mail, access FROM users_field_data WHERE access BETWEEN $startdate and $endate")->fetchAll();
Here is twig where i Called date
{{ result.access|format_date('custom', 'F j, Y')|e }}