Keyword

[Solved] Date format to x days ago

  • Remus Ionita
  • Remus Ionita's Avatar Topic Author
  • Offline
  • Junior Member
More
12 years 9 months ago - 12 years 9 months ago #60587 by Remus Ionita
[Solved] Date format to x days ago was created by Remus Ionita
Hi,
First off all thank you for this amazing extension. Keep up the good work!
Secondly I'm using K2 on my site (here -> www.mtrailer.ro/pagina-de-teste/) and I would like to change the format of the date. Now it's like this DATE_FORMAT_LC2 (%A, %d %B %Y %H:%M) and I want to change it to added 2 days ago or 3 months ago or if it's from today, 10 hours, 16 minutes ago.
Do you have any ideas?
Thanks!

Regards.

Please Log in or Create an account to join the conversation.

  • Remus Ionita
  • Remus Ionita's Avatar Topic Author
  • Offline
  • Junior Member
More
12 years 9 months ago #60588 by Remus Ionita
Replied by Remus Ionita on topic Re: Date format to x days ago
Anyone?
I'm using Joomla 1.5.25 and K2 2.5.4

Please Log in or Create an account to join the conversation.

More
12 years 9 months ago - 12 years 9 months ago #60589 by jim
Replied by jim on topic Re: Date format to x days ago
Hi ,

I have no idea why this forum is actually running, i went into ask help and all i see are streaming links to football matches. :S , perhaps you should find a moderators post and reply to his and see if you can get some help like that, otherwise your thread gets bumped down and never to bee seen or replied. In other words this forum lacks so much professional help its amazing why its actually under a k2 banner. :angry:

Please Log in or Create an account to join the conversation.

  • Remus Ionita
  • Remus Ionita's Avatar Topic Author
  • Offline
  • Junior Member
More
12 years 9 months ago #60590 by Remus Ionita
Replied by Remus Ionita on topic Re: Date format to x days ago
:lol: good point...

Please Log in or Create an account to join the conversation.

  • Kannan Naidu Venugopal
  • Kannan Naidu Venugopal's Avatar
  • Offline
  • Platinum Member
  • Aham Brahmasmi
More
12 years 9 months ago - 12 years 9 months ago #60591 by Kannan Naidu Venugopal
Replied by Kannan Naidu Venugopal on topic Re: Date format to x days ago
Hi Remus,

You can read some php documentation on date_diff and see some examples on how it's done. There is such feature in K2 Comments module where you can display the date as relative. To make it work in item view or category view requires some programming skills.

K2 Rocks \m/

Please Log in or Create an account to join the conversation.

  • Kannan Naidu Venugopal
  • Kannan Naidu Venugopal's Avatar
  • Offline
  • Platinum Member
  • Aham Brahmasmi
More
12 years 9 months ago #60592 by Kannan Naidu Venugopal
Replied by Kannan Naidu Venugopal on topic Re: Date format to x days ago
I just did a test, if you want to display the x day ago and time. Follow this guide, i'm sure there's a simpler way to do it in joomla.

Copy the php code found here and paste it into components/com_k2/views/item/view.html.php

Just remove the <?php ?> tags from the code.

Paste below this line (line 360)
					
K2 Rocks \m/

Please Log in or Create an account to join the conversation.

  • Remus Ionita
  • Remus Ionita's Avatar Topic Author
  • Offline
  • Junior Member
More
12 years 9 months ago - 12 years 9 months ago #60593 by Remus Ionita
Replied by Remus Ionita on topic Re: Date format to x days ago
Hi,
Thanks Kannan Naidu for the reply.
Unfortunately it's not working....or I did something wrong..Can you please give me the files (view.html.php and item.php) that are working for you?
Thanks.

Regards.

Please Log in or Create an account to join the conversation.

  • Kannan Naidu Venugopal
  • Kannan Naidu Venugopal's Avatar
  • Offline
  • Platinum Member
  • Aham Brahmasmi
More
12 years 9 months ago #60594 by Kannan Naidu Venugopal
Replied by Kannan Naidu Venugopal on topic Re: Date format to x days ago
Hi Remus,

Did you get any error message ? Attached are the files.



K2 Rocks \m/
Attachments:

Please Log in or Create an account to join the conversation.

  • Remus Ionita
  • Remus Ionita's Avatar Topic Author
  • Offline
  • Junior Member
More
12 years 9 months ago - 12 years 9 months ago #60595 by Remus Ionita
Replied by Remus Ionita on topic Re: Date format to x days ago
Hi,
No error message. Just not working. (as you can see here -> www.mtrailer.ro/pagina-de-teste/)
item.php -> components/com_k2/templates/default
view.html.php -> components/com_k2/views/item
Did I uploaded them in the wrong folder?

edit:
Now I see...
www.mtrailer.ro/pagina-de-teste/item/5-romania.html -> Warning: strtotime() expects parameter 1 to be string, object given in /home/rmtrai17/public_html/components/com_k2/views/item/view.html.php on line 243
future event
Also I don't want the date from the item...date from category_item....

Please Log in or Create an account to join the conversation.

  • Kannan Naidu Venugopal
  • Kannan Naidu Venugopal's Avatar
  • Offline
  • Platinum Member
  • Aham Brahmasmi
More
12 years 9 months ago #60596 by Kannan Naidu Venugopal
Replied by Kannan Naidu Venugopal on topic Re: Date format to x days ago
Ok, i was testing it on Joomla 1.7.3

K2 Rocks \m/

Please Log in or Create an account to join the conversation.


Powered by Kunena Forum