Sign Up for OSTraining

Welcome, Guest
Username: Password: Remember me

TOPIC: How can I change the date format for a module?

How can I change the date format for a module? 1 year 2 months ago #39659

  • ellen
  • ellen's Avatar
  • OFFLINE
  • OSTarlet
  • Posts: 50
  • Karma: 0
I am using Joomla 2.5. I want to show the last time a visitor logged in to the site. I added the code:
echo "<p>Your last visit was {$user->lastvisitDate}";
to the default.php file of the mod_login module.I created a folder and placed it in my html folder in my template folder. It works, but I don't like the date format. How and where do I fix this? I tried modifying the language file EN-gb.ini both in the override file and the actual file (I know, I know, I wasn't going to leave it there, just testing it!) with DATE_FORMAT_LC4=%m.%d.%y. It didn't change the date format.
Can you help me?
Please become a member of OSTraining to reply to this post.

How can I change the date format for a module? 1 year 2 months ago #39666

  • Nick
  • Nick's Avatar
  • OFFLINE
  • Administrator
  • Posts: 16744
  • Thank you received: 373
  • Karma: 55
Hi Ellen,

Wow, great job so far! :)

You could try editing the other DATE_FORMAT_LCs. I never have figured out what the different numbers control for sure and it doesn't appear that there's any documentation for them.

If that doesn't help, in your template override you could do something similar to the following instead:
echo "<p>Your last visit was " . date("your php date format here", strtotime($this->u->lastvisitDate));

Kind regards,
Nick
Follow us on Twitter - twitter.com/OSTraining
Like us on Facebook - facebook.com/ostraining
Please become a member of OSTraining to reply to this post.

How can I change the date format for a module? 1 year 2 months ago #39670

  • ellen
  • ellen's Avatar
  • OFFLINE
  • OSTarlet
  • Posts: 50
  • Karma: 0
Can you breakdown what you mean by
echo "<p>Your last visit was " . date("your php date format here", strtotime($this->u->lastvisitDate));
what do you mean by 'your php date format here"?
Please become a member of OSTraining to reply to this post.

How can I change the date format for a module? 1 year 2 months ago #39698

  • Nick
  • Nick's Avatar
  • OFFLINE
  • Administrator
  • Posts: 16744
  • Thank you received: 373
  • Karma: 55
Hi Ellen,

Sure, could you take a look at the following documentation and let me know if it helps or not? php.net/manual/en/function.date.php

Kind regards,
Nick
Follow us on Twitter - twitter.com/OSTraining
Like us on Facebook - facebook.com/ostraining
Please become a member of OSTraining to reply to this post.

How can I change the date format for a module? 1 year 2 months ago #39703

  • ellen
  • ellen's Avatar
  • OFFLINE
  • OSTarlet
  • Posts: 50
  • Karma: 0
I tried using
echo "<p>Your last visit was " . date("l  F d Y", strtotime($this->u->lastvisitDate));
in place of
echo "<p>Your last visit was {$user->lastvisitDate}";
and got an error message.Maybe I didn't do it right. I don't really know php.
Ellen
Please become a member of OSTraining to reply to this post.

How can I change the date format for a module? 1 year 2 months ago #39732

  • Nick
  • Nick's Avatar
  • OFFLINE
  • Administrator
  • Posts: 16744
  • Thank you received: 373
  • Karma: 55
Hi Ellen,

What error message did you get?

Kind regards,
Nick
Follow us on Twitter - twitter.com/OSTraining
Like us on Facebook - facebook.com/ostraining
Please become a member of OSTraining to reply to this post.

How can I change the date format for a module? 1 year 2 months ago #39762

  • edandrea
  • edandrea's Avatar
  • OFFLINE
  • OSTop Dog
  • Posts: 3106
  • Thank you received: 7
  • Karma: 0
Hi Ellen,
I don't think the code is correct. Go back to the page Nick recommended and study the examples. Maybe copy and paste one that's similar to what you want and see if it generates an error. (or at least try one that you know works for sure.)

Ed
Please become a member of OSTraining to reply to this post.

Sign Up for OSTraining

Powered by Kunena Forum

Open Source Training is not affiliated with or endorsed by the Joomla, WordPress or Drupal projects.
All product names and trademarks are the property of their respective owners.

Copyright 2013 Open Source Training, LLC. All rights reserved.