Early Bird Registration for DrupalCon Portland 2024 is open! Register by 23:59 PST on 31 March 2024, to get $100 off your ticket.
date() doesnt respect the timezone and language settings for drupal users. Plus I guess it isn't Drupal coding standard to use date(). So you should use Drupals own date function: format_date()
In node--teaser.tpl.php change
<div class="teaser-created-month">
<?php print date('M',$node->created); ?>
</div>
<div class="teaser-created-day">
<?php print date('d',$node->created); ?>
</div>
to
<div class="teaser-created-month">
<?php print format_date($node->created,'custom','M'); ?>
</div>
<div class="teaser-created-day">
<?php print format_date($node->created,'custom','d'); ?>
</div>
Comment | File | Size | Author |
---|---|---|---|
#3 | 1309740-3.patch | 632 bytes | gaurav.kapoor |
Comments
Comment #1
Thremulant CreditAttribution: Thremulant commentedHi, I'm having a problem with this code, I hope you can help me:
BUT, when I go to the page, this is what is displayed:
MAR, 07/28/2015 - 16:20
JUL
31
2015
Why is this showing the wrong month and date?????
Thanks,
Daniel.
Comment #2
dagomar CreditAttribution: dagomar commentedWell, is the $date variable created with $node->created, or with something else?
Comment #3
gaurav.kapoor CreditAttribution: gaurav.kapoor commentedDid changes as suggested in comments.
Comment #4
gaurav.kapoor CreditAttribution: gaurav.kapoor at OpenSense Labs commentedComment #5
BhumikaVarshney CreditAttribution: BhumikaVarshney as a volunteer and at OpenSense Labs commentedThe above patch use Drupal coding standard for date().
Comment #7
gaurav.kapoor CreditAttribution: gaurav.kapoor commented