Grokking Drupal dates and time zones

Grokking Drupal dates and time zones

in

I've run into a surprising amount of trouble trying to get time zones working properly in Drupal via the Date module. For instance, the date in the database might not align with the displayed date in the node, and when I go to edit the date in CCK, it displays yet another date. It's gotten so bad that I've had nightmares where calendars are bludgeoning me with timestamps, complaining that I just don't understand them, why don't I understand...

So I finally decided to dig a little deeper, and it's actually some simple stuff that I can summarize in a few bullet points:

  1. The date module saves dates in UTC, which stands for Coordinated Universal Time. So, regardless of your server, location or personal preference, when a date CCK field stores the date, it will offset it to match UTC. That means that if you and I make a post at the same time, even if we're in different time zones the date in the database will be the same for both of us.
  2. The CCK date field widget and it's output on a node might show two different things if you don't set the time zone setting in the CCK field. I set mine to match my site's so that I only have one variable to change later.
  3. Depending on what you need to do, you might need to explicitly set your time zone in PHP. For example, in order to get the date() function to output the time in my set time zone, I had to use date_default_timezone_set('America/Boise'). I might be missing something here, or need to update the date module, but this works for now.


Discussion on this post:

Oh man I have also have

Oh man I have also have problems during Drupal installation. Little expertise required for building drupal application or plugins. In fact drupal is very rich content management system. I used drupal plugin with my web sites.Air Jordan Basektball Shoes

First of all you have to set

First of all you have to set the time in your operating system. If again you can't get rid of problem , you can check with the following coding. Hope this will solve your problem.
$result1=db_query("select field_enventdate_value as condate from content_type_createvent where field_enventdate_value > now() AND field_enventdate_value <= now()+interval 15 minute");

while($result2=db_fetch_object($result1))
{

print format_date($result2->condate, 'custom', 'M j Y').'
';

}
Regards,
Robert kardashian

Recently I have tried my

Recently I have tried my level best to get clean urls but I am totally failed due to lot of information available online but all is not helpful for me. Its a common problem that many times we are not able to install module correctly in open source cms

Post new comment

The content of this field is kept private and will not be shown publicly.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.

More information about formatting options

Captcha
This question is for testing whether you are a human visitor. Once you register you won't have to fill this out.
Implied By Design Logo