Results 1 to 8 of 8

Thread: (solved) How to display only the date in news ?

  1. #1
    User
    Join Date
    04-01-10.
    Posts
    251

    Default (solved) How to display only the date in news ?

    Hello,
    news_latest displays date and time by default. How can I display only the date ?

    Here is the code
    PHP Code:
    <?php if ($this->hasMetaFields): ?>
        <h3 class="info"><time datetime="<?= $this->datetime ?>" itemprop="datePublished"><?= $this->date ?></time></h3>
      <?php endif; ?>
    Thanks.
    Last edited by charled; 09/24/2020 at 22:18.

  2. #2
    User
    Join Date
    04-01-10.
    Posts
    251

    Default

    Finally found. Replaced by :
    PHP Code:
      <?php echo date('d/m/Y'$this->time?>

  3. #3
    User Andreas's Avatar
    Join Date
    07-11-09.
    Location
    Mönchengladbach
    Posts
    495

    Default

    No, you should use the Contao method Date::parse. Else you won't get the translated dates for example.

    https://github.com/contao/core-bundl....php#L549-L591

    PHP Code:
     <?= \Date::parse('d/m/Y'$this->time?>
    Web-Development, Freelancer, Burgtech, XHTML, HTML5, CSS, PHP, Javascript, MooTools, MySQL and more
    Amazon wishlist

  4. #4
    User
    Join Date
    04-01-10.
    Posts
    251

    Default

    Thanks Andreas.

  5. #5
    User Andreas's Avatar
    Join Date
    07-11-09.
    Location
    Mönchengladbach
    Posts
    495

    Default

    My pleasure. It's not necessary as long as you use d, m and Y but you should get used to using Contao methods.
    Web-Development, Freelancer, Burgtech, XHTML, HTML5, CSS, PHP, Javascript, MooTools, MySQL and more
    Amazon wishlist

  6. #6
    User
    Join Date
    04-01-10.
    Posts
    251

    Default

    Quote Originally Posted by Andreas View Post
    ...but you should get used to using Contao methods.
    You're right but so much too learn... ;-)

  7. #7
    User Andreas's Avatar
    Join Date
    07-11-09.
    Location
    Mönchengladbach
    Posts
    495

    Default

    Me too
    Web-Development, Freelancer, Burgtech, XHTML, HTML5, CSS, PHP, Javascript, MooTools, MySQL and more
    Amazon wishlist

  8. #8
    User
    Join Date
    04-01-10.
    Posts
    251

    Default

    I think you are a bit ahead ;-)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •