Guest User

Untitled

a guest
Dec 16th, 2017
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.10 KB | None | 0 0
  1. Array
  2. (
  3. [0] => Array
  4. (
  5. [0] => Array
  6. (
  7. [hour] => 5
  8. [minute] => 0
  9. [period] => AM
  10. )
  11.  
  12. [1] => Array
  13. (
  14. [hour] => 5
  15. [minute] => 0
  16. [period] => PM
  17. )
  18.  
  19. [2] => Array
  20. (
  21. [day_off] => 0
  22. )
  23.  
  24. )
  25. )
  26.  
  27. $timezone = new DateTimeZone("Asia/Kolkata"); //Converting GMT to IST.
  28.  
  29. $startTime = new DateTime();
  30. $startTime->setTime($Array[1][0]["hour"], $Array[1][0]["minute"]);
  31. $startTime->setTimezone($timezone);
  32. $startTime->format('h:i a'); //output 10:30 PM // Should be 10:30 AM
  33.  
  34. $endTime = new DateTime();
  35. $endTime->setTime($Array[1][1]["hour"], $Array[1][1]["minute"]);
  36. $endTime->setTimezone($timezone);
  37. $endTime->format('h:i a'); //output 10:30 PM //ok
  38.  
  39. So My $startTime and $endTime both has the same value of `10:30` PM but I want the startTime to have value of `10:00 AM`because its period was `AM` in the array.
Add Comment
Please, Sign In to add comment