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>	
CommentFileSizeAuthor
#3 1309740-3.patch632 bytesgaurav.kapoor
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Thremulant’s picture

Issue summary: View changes

Hi, I'm having a problem with this code, I hope you can help me:

<div class="fecha">
  <div class="mes">
    <?php print $date; ?>
  </div>
  <div class="mes">
    <?php print format_date($node->created,'custom','M'); ?>
  </div>
  <div class="dia">
    <?php print format_date($node->created,'custom','t'); ?> 
  </div>
  <div class="año">
    <?php print format_date($node->created,'custom','Y'); ?>
  </div>
</div>

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.

dagomar’s picture

Well, is the $date variable created with $node->created, or with something else?

gaurav.kapoor’s picture

Status: Active » Needs review
FileSize
632 bytes

Did changes as suggested in comments.

gaurav.kapoor’s picture

BhumikaVarshney’s picture

Status: Needs review » Reviewed & tested by the community

The above patch use Drupal coding standard for date().

  • gaurav.kapoor committed a0a9174 on 7.x-4.x
    Issue #1309740 by gaurav.kapoor: Use format_date instead of date in node...
gaurav.kapoor’s picture

Status: Reviewed & tested by the community » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.