[support] question about drupal 7

Carl Wiedemann carl.wiedemann at gmail.com
Tue Sep 20 04:56:24 UTC 2011


There are two problems with this approach.

Firstly, date() does not account for user timezones. You could use Drupal's
format_date() function instead. It works similarly.
http://api.drupal.org/api/drupal/includes--common.inc/function/format_date

Secondly, this is incompatible with caching. You could use JavaScript to get
around this problem. On a somewhat related note, you can also use JavaScript
to show relative date information, similar to this approach
http://37signals.com/svn/posts/1557-javascript-makes-relative-times-compatible-with-caching(In
this example, I'd recommend using HTML 5 data attributes. See
http://ejohn.org/blog/html-5-data-attributes/ for more information.)

Carl Wiedemann
Website design and development consulting
carl.wiedemann at gmail.com | skype: c4rlww



On Mon, Sep 19, 2011 at 9:19 PM, Cory Gilliam <imaaxa at gmail.com> wrote:

> Hey Jim,
>
> If you want it hard coded into the site add this line to your page.tpl.php
> for your theme:
>
> <?php print date('l, F j, Y g:i a T') ?>
>
> This will print the date time like: Sunday September 18, 2011 5:15 am EST.
> If you want to tweek the way the time and date display, go to
> http://us.php.net/manual/en/function.date.php for a list of date / time
> parts and examples. So you can theme the date and time, you can wrap this in
> html tags like so:
>
> <div id="myTimeAndDate" class="myTimeAndDate">
>   <?php print date('l, F j, Y g:i a T') ?>
> </div>
>
> Hope this helps,
> Cory
>
> On Mon, Sep 19, 2011 at 6:30 PM, Jim Ruby <jim at v-community.com> wrote:
>
>> I would like to display current date and time, what would be the best way
>> to
>> do this in drupal 7? I would like to display either the local time pst or
>> the users that is visiting their local time. These would be anonymous
>> visitors.
>>
>> Thanks.
>>
>> Follow me on:
>> Twitter: http://twitter.com/1rubytweets
>> Facebook: http://www.facebook.com/profile.php?id=1058306793
>> Join me on:
>> Yahoo: jruby6767
>> Msn: jruby at charter.net
>>
>>
>>
>> --
>> [ Drupal support list | http://lists.drupal.org/ ]
>>
>
>
>
> --
> Cory Gilliam
> Knoxville, TN 37921
> imaaxa at gmail.com
> 865.335.3250
>
>
>
> --
> [ Drupal support list | http://lists.drupal.org/ ]
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.drupal.org/pipermail/support/attachments/20110919/f1ab5d7c/attachment.html 


More information about the support mailing list