Community

Drupal 7: Warning: date_timezone_set() expects parameter 1 to be DateTime, boolean given in format_date()

I have a site I just upgraded from D6 to D7. I have a view that filters for a content type 'events' which uses the 'date-field'. One of my views generates warning messages when you're visiting the page:

Warning: date_timezone_set() expects parameter 1 to be DateTime, boolean given in format_date() (line 2006 of C:\xampp\htdocs\test\includes\common.inc).

I used NetBeans to acquire the following information:

Debugging date_timezone_set:

Iteration #1

Variables:
Superglobal

Call Stack:
index.php.{main}:17

---

Iteration #2

Variables:
date_time
date: string "2012-07-12 17:30:00"
timezone_type: integer 1

---

Iteration #3

Variables:
date_time
date: string "2012-07-12 17:30:00"
timezone_type: integer 1
timezone: string "+00:00"

---

Iteration #4

Variables:
date_time
date: string "2012-07-12 17:30:00"
timezone_type: integer 1
timezone: string "+00:00"

---

Iteration #5

Variables:
date_time
date: string "2012-08-09 17:30:00"
timezone_type: integer 1
timezone: string "+00:00"

---

Iteration #6

Variables:
date_time
date: string "2012-07-26 18:30:00"
timezone_type: integer 1
timezone: string "+00:00"

---

Iteration #7

Variables
date_time
date: string "2012-09-07 16:00:00"
time_zone_type: integer 1
timezone: string "+00:00"

---

Iteration #8

Variables
date_time
date: string "2012-09-07 16:00:00"
time_zone_type: integer 1
timezone: string "+00:00"

---

Iteration #9

Variables
date_time
boolean: 0

---

Iteration #10

Variables
date_time
date: string "2012-09-06 15:00:00"
time_zone_type: integer 1
timezone: string "+00:00"

---

Iteration #11

Variables
date_time
date: string "2012-09-06 15:00:00"
time_zone_type: integer 1
timezone: string "+00:00"

---

** Special Iteration(s) **

Variables
date_time
boolean: 0

Comments

Additional errors

When I attempt to create a new content 'events' and save it, I receive two additional errors on the view page '[my:site]/events':

Warning: date_format() expects parameter 1 to be DateTime, boolean given in format_date() (line 2016 of C:\xampp\htdocs\test\includes\common.inc)

It appears that, new content is being saved with incorrect format.

Views template files

Silly mistake. My custom 'views template files' had bad code. Instead of having code like:

print format_date($date_start[0], 'custom', 'g:ia')

I instead referred to an array element that didn't exist:

print format_date($date_start[1], 'custom', 'g:ia')