We're trying out date_popup for Advanced Poll, but I'm getting this error when using the date_popup type:

Fatal error: Call to undefined function: date_create() in .../sites/all/modules/date/date_api.module on line 875

I have enabled the following modules: content, date, date api, date copy, date php4, date popup, and date timezone.

If I manually edit date_php4.module to also include date_php4.inc I then get this error:

Fatal error: Unknown function: date_handle_timezones() in .../sites/all/modules/date/date_php4/date_php4.inc on line 817

Also, before manually including date_php4.inc, I get a fatal error when going to admin/settings/date-time: Fatal error: Unknown function: timezone_identifiers_list() in .../sites/all/modules/date/date_api.module on line 392. After including the file I get 3 warnings in timezone_identifiers_list and a foreach error in date_api.module line 375.

Sorry the combined error reporting, I don't know if these are the same issue or separate ones. My server runs PHP 4.4.7.

Comments

karens’s picture

It's working pretty well in PHP5 now and I'm just getting ready to swing back through and see where the PHP4 wrapper functions may have quit working since I last tested them.

Specific reports like this are helpful since I can jump right to these things to see what is missing.

I'll take a look for this.

karens’s picture

Actually there is one more thing to check. The PHP4 wrappers are now in a separate module that you must enable on PHP4. Did you enable that? There is a hook_requirements error to tell you about that, but that hook_requirements error only displays on the admin page.

[Edit] Oops, I see you already said you have that enabled. Sorry about that!

karens’s picture

Status: Active » Fixed

I just committed a fix for these problems. You should now be able to use this without program errors. At this point I can get it to work and save the right values, but I still see some places where the PHP4 version is not getting the timezone adjustment right in places where it does work right in PHP5, so I need to do some more work on the wrapper functions that handle the timezone conversion.

But this posted issue should be fixed.

ChrisKennedy’s picture

Hey it works now, awesome :) Thanks.

smileyrose’s picture

Status: Fixed » Postponed (maintainer needs more info)

Same problem but me, I'm using ubuntu in my php5.
My php5 is working properly but when I was using it in my project and my codes contains date_create() function Fatal error displayed in my browser.

Error appeared like this
Fatal error: Call to undefined function date_create() in /var/www/repos/utils.inc on line 68

What should I do?

Tanx in advance

karens’s picture

If you're using PHP 5.2 or higher, date_create() is a native PHP function which should always be available. The date module can't do anything about that one way or another and I can't think of any reason why you'd get that message.

If you're using a version of PHP 5 less than 5.2, date_create() may *not* be available, and the only way you can get this to work is to enable the Date PHP4 module, which creates emulations of date_create that work where it is not natively available.

smileyrose’s picture

How can I enable the Date php4 module? I'm using php-5.1.6.

ChrisKennedy’s picture

Status: Postponed (maintainer needs more info) » Fixed

admin/build/modules ...

smileyrose’s picture

admin/build/modules ...
that is for what? I can't find that.

I am using these ff:
ubuntu6
php-5.1.6
apache 2

until now the fatal error still there.I can't work properly. help me guys.

Thanx in advance.
Merry Xmas.

smileyrose’s picture

guys please help me to solve my problem above.Up to now i can't find any solution for that.
Fatal error: Call to undefined function: date_create();

Thank you in advance.

karens’s picture

If you are using PHP version less than 5.2 you need to enable the Date PHP4 module or this won't work. It's in the same place where you enabled the Date API and other Drupal modules, listed as a part of the Date API package.

smileyrose’s picture

In my phpinfo(); The date/time support is enabled. I also tried to change the function from date_create() to DateTime::_construct() which contains the same parameter and return type, but when I was changed it this error display(Fatal error: Class 'DateTime' not found).

karens’s picture

PHP versions earlier than 5.2 have incomplete and buggy date/time support. As I have said three times already, you need to enable the Date Php4 module. If you have control over your configuration, turn the native date/time support *off* since it does not work right in those early versions.

smileyrose’s picture

I want to enable the Date Php4 module. but i can't find this (admin/build/modules). I also tried to search it in Google.I found this link:http://drupal.org/project/date. Do i have to download that and install it?

asimmonds’s picture

@smileyrose
- Fatal error: Call to undefined function date_create() in /var/www/repos/utils.inc on line 68

This error that you have mentioned, is in file "utils.inc". This file is in neither date module or Drupal core. I suspect it's not even a Drupal related problem.

smileyrose’s picture

Yup...your right..It's in "utils.inc" because we used date_create() function there. Any suggestion to solve this?What should I do?

karens’s picture

Status: Fixed » Closed (fixed)

Why in the world are you filing an issue against the Date module if you don't have the file from http://drupal.org/project/date? That's what this project is. The Date package has several modules, one is the Date API, one is the CCK Date module, one is the Date PHP4 module, and there are a couple others. I can't even comprehend why you would be filing an issue against the Date package without having the package installed on your system.

The Date PHP4 module creates a wrapper function for date_create() that works in versions of PHP earlier than PHP 5.2. It will allow you to use date_create() in your own custom code. To use that function in custom code you must have Date API and Date PHP4 and Date Timezone installed. Even then, there are some limitations -- it won't do everything that the native PHP5 code does, just enough to allow me to use those functions in the Date module. You'll have to read the PHP Docs in the Date PHP4 module to see how it works.

It sounds like you don't have any part of the Date module installed, so this is not a Date issue, and this thread is closed.

davidwhthomas’s picture

This error occurs because your version of PHP is out of date.

You can fix it by either

* updating the PHP install on your server, or

* enabling the date_php4 module via the database:

UPDATE `system` SET `status` = '1' WHERE NAME = 'date_php4' ;

DT