bongzilla

Untitled

May 4th, 2021 (edited)
132
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2. $usersTimezone = 'Europe/Kiev';
  3. $date = new DateTime( 'now', new DateTimeZone($usersTimezone) );
  4. $today = $date->format("Y-m-d");
  5. $tomorrow = date('Y-m-d', strtotime("tomorrow"));
  6.  
  7. $default_opts = '{"selector":".datetimepicker","datepicker":"on","timepicker":"off","minDate":"on","min_date":"","max_date":"","days_offset":"0","dateformat":"YYYY-MM-DD","step":"60","minTime":"00:00","maxTime":"23:59","offset":"0","hourformat":"hh:mm A","inline":"off","placeholder":"off","preventkeyboard":"off","locale":"en","theme":"default","load":"full","disabled_days":"","disabled_calendar_days":[],"allowed_times":"","sunday_times":"","monday_times":"","tuesday_times":"","wednesday_times":"","thursday_times":"","friday_times":"","saturday_times":"","dayOfWeekStart":"1","i18n":{"en":{"months":["Січень","Лютий","Березень","Квітень","Травень","Червень","Липень","Серпень","Вересень","Жовтень","Листопад","Грудень"],"dayOfWeekShort":["Нд","Пн","Вт","Ср","Чт","Пт","Сб"],"dayOfWeek":["Неділя","Понеділок","Вівторок","Середа","Четвер","П’ятниця","Субота"]}},"format":"YYYY-MM-DD","clean_format":"Y-m-d","value":"","timezone":"","utc_offset":"+3","now":""}';
  8. $json_opts = json_decode($default_opts, true);
  9. array_push($json_opts["disabled_calendar_days"], $today);
  10.  
  11. if($date->format('H') >= 18) {
  12.     array_push($json_opts["disabled_calendar_days"], $tomorrow);
  13. }
  14.  
  15. $new_opts = json_encode($json_opts);
  16.  
  17. echo "<script>$(document).ready(function(){ const datepickeropts = {$new_opts}; $(\"#billing_postcode\").datetimepicker(datepickeropts); dtp_init(); });</script>";
  18.  
  19. ?>
RAW Paste Data