Gossamer Forum
Home : Products : Gossamer Links : Development, Plugins and Globals :

How to display days since add and last modified

Quote Reply
How to display days since add and last modified
As subject says, I was wondering if there was a way to display:

1. Number of days since listing was added (current date - add date)
2. Number of days since listing was last modified (current date - modified date)

Is this possible via UltraGLobal or any other global?

Thanks.

Vishal
-------------------------------------------------------
Quote Reply
Re: [SWDevil.Com] How to display days since add and last modified In reply to
Hi,

Not 100% sure - but you should be able to do with something like this:


Code:
<%GT::Date::date_diff($Add_Date,GT::Date::date_get)%>

..and:

Code:
<%GT::Date::date_diff($Mod_Date,GT::Date::date_get)%>

May not be as simple as that (cos the date formats for $Add_Date and $Mod_Date are converted when passed to the template - so may require a little cleverer solution).

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] How to display days since add and last modified In reply to
hum :( not working.. its giving 0 as out put for both.. Here is what I am using:

Add Date: <%GT::Date::date_diff($Add_Date,GT::Date::date_get)%> <br>
Mod Date: <%GT::Date::date_diff($Mod_Date,GT::Date::date_get)%>

and here is the output:

Add Date: 0
Mod Date: 0

Vishal
-------------------------------------------------------
Quote Reply
Re: [SWDevil.Com] How to display days since add and last modified In reply to
Try this:

Code:
<%set today = GT::Date::date_get%>
Add Date: <%GT::Date::date_diff($Add_Date,$today)%> <br>
Mod Date: <%GT::Date::date_diff($Mod_Date,$today)%>

If not, what format do you have set in
Code:
Setup > Date Options > date_user_format
?

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] How to display days since add and last modified In reply to
Output for that code is -14495

date_user_format = %dd% %mmm% %yyyy%

Vishal
-------------------------------------------------------
Quote Reply
Re: [SWDevil.Com] How to display days since add and last modified In reply to
Ok, stab in the dark - but try:

<%set _today = GT::Date::date_get%>
<%set today = GT::Date::date_transform ($_today, "%dd% %mmm% %yyyy% ", "%yyyy%-%mm-%dd%")%>
Add Date: <%GT::Date::date_diff($Add_Date,$today)%> <br>
Mod Date: <%GT::Date::date_diff($Mod_Date,$today)%>


Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] How to display days since add and last modified In reply to
hum... back to:

Add Date: 0
Mod Date: 0

Vishal
-------------------------------------------------------
Quote Reply
Re: [SWDevil.Com] How to display days since add and last modified In reply to
Ok try some debugging:

Code:
<%set _today = GT::Date::date_get%>
<%set today = GT::Date::date_transform ($_today, "%yyyy%-%mm-%dd%", "%dd% %mmm% %yyyy%")%>
today = <%today%> <br />
Add Date: <%GT::Date::date_diff($Add_Date,$today)%> <br>
Mod Date: <%GT::Date::date_diff($Mod_Date,$today)%>

(I also fixed something, which may have been causing it not to work =))

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] How to display days since add and last modified In reply to
:( Still no success

today =
Add Date: 0
Mod Date: 0

Vishal
-------------------------------------------------------
Quote Reply
Re: [SWDevil.Com] How to display days since add and last modified In reply to
Send over GLinks details, and I'll try to take a look later / tomorrow. Really busy atm.

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] How to display days since add and last modified In reply to
Check your pm.. its there And I am adding above code in link.html at the end.

Vishal
-------------------------------------------------------
Quote Reply
Re: [SWDevil.Com] How to display days since add and last modified In reply to
Hi,

You gave the wrong date format ;)

This now works:

Code:
<%GT::Date::date_set_format("%ddd% %mmm% %dd% %yyyy%")%>
<%set _today = GT::Date::date_get%>
Add Date: <%GT::Date::date_diff($_today,$Add_Date)%> <br>
Mod Date: <%GT::Date::date_diff($_today,$Mod_Date)%>


The bit in bold needs to match up to whatever you have in your "Date Options" section - otherwise it won't work.

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] How to display days since add and last modified In reply to
Hey you got it..... wow.. this is just insane.. I mean it open up like a zillion new ideas on how to format or display info..

Cool.

Thanks again.

Vishal
-------------------------------------------------------
Quote Reply
Re: [Andy] How to display days since add and last modified In reply to
Hi Andy,

Was wondering on how to display age for Listing & User:

Example : I just used the dates for easy example:
So for Link it can be like :::: (Based on the Add Date)
Listed Since: April 22, 2007 (2 years 4 months 18 days)

Last Updated :::: (Based on the Mod Date)
Last Updated: April 22, 2008 (1 years 4 months 18 days)


For Users it can be like :::: (Based on the User Registration Date)
Member Since April 22, 2006 (3 years 4 months 18 days)

Vishal
-------------------------------------------------------
Quote Reply
Re: [SWDevil.Com] How to display days since add and last modified In reply to
Depends on how you are using - are you using GComm?

I'm not sure without looking, to see how the "signup date" is stored for users (bit busy to start looking I'm afraid)

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] How to display days since add and last modified In reply to
Nope.. not using GCom.. just GLinks.

I noticed that there is no Date field in User Tables, so simply created one (with the name Signup_Date & Column Type as "Date"). Or in other words, its set same as Link Add Date but under user tables.

Vishal
-------------------------------------------------------
Quote Reply
Re: [SWDevil.Com] How to display days since add and last modified In reply to
Ok, and what format (when you look in mysqlman), does it show for that field?

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] How to display days since add and last modified In reply to
I just checked in the GLinks help section it shows "DATE: This stores a date defaulting to yyyy-mm-dd format"

Vishal
-------------------------------------------------------
Quote Reply
Re: [SWDevil.Com] How to display days since add and last modified In reply to
It is on the same development site that I send you last login info.

Vishal
-------------------------------------------------------
Quote Reply
Re: [SWDevil.Com] How to display days since add and last modified In reply to
Ok, well try this then:

Code:
<%GT::Date::date_set_format("%yyyy%-%dd%-%mm%")%>
<%set _today = GT::Date::date_get%>
Since Signup: <%GT::Date::date_diff($_today,user.DateField)%>

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] How to display days since add and last modified In reply to
No Success, here is what I am doing:

In footer for user_profile.html page (User Edit Profile Plugin)
am having this code
Code:
<%GT::Date::date_set_format("%yyyy%-%dd%-%mm%")%>
<%set _today = GT::Date::date_get%>
Since Signup: <%GT::Date::date_diff($_today,user.Signup_Date)%>

Output
Code:
0 Since Signup: 14497

Vishal
-------------------------------------------------------
Quote Reply
Re: [SWDevil.Com] How to display days since add and last modified In reply to
Mmm, sometimes it can be due to the user, stuff

Try doing:
Code:
<%GT::Date::date_set_format("%yyyy%-%dd%-%mm%")%>
<%set _today = GT::Date::date_get%>
<%set tmp = user.Signup_Date%>
Since Signup: <%GT::Date::date_diff($_today,$tmp)%>

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] How to display days since add and last modified In reply to
Still the same output.

0 Since Signup: 14497

Vishal
-------------------------------------------------------
Quote Reply
Re: [SWDevil.Com] How to display days since add and last modified In reply to
Ok not sure - will try and have a look later - mega busy atm.

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] How to display days since add and last modified In reply to
Thanks for the help, will be waiting for your reply.

Vishal
-------------------------------------------------------
Quote Reply
Re: [SWDevil.Com] How to display days since add and last modified In reply to
Hi,

This works:

Code:
<%GT::Date::date_set_format("%yyyy%-%dd%-%mm%")%>
<%set _today = GT::Date::date_get%>
<%set tmp = "2009-07-10"%>
Since Signup: <%GT::Date::date_diff($tmp,$_today)%>

..so maybe try:

Code:
<%GT::Date::date_set_format("%yyyy%-%dd%-%mm%")%>
<%set _today = GT::Date::date_get%>
Since Signup: <%GT::Date::date_diff($Signup_Date,$_today)%>

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] How to display days since add and last modified In reply to
 

Here is the input:
Code:
<%Signup_Date%> <br>

<%GT::Date::date_set_format("%yyyy%-%dd%-%mm%")%>
<%set _today = GT::Date::date_get%>
Since Signup: <%GT::Date::date_diff($Signup_Date,$_today)%>


Here is the output:
Code:
2008-08-25
0 Since Signup: 120

Now the funny thing is, if I manually change Signup_date to 2008-08-09 output changes to

Code:
2008-08-09
0 Since Signup: -367

Vishal
-------------------------------------------------------
Quote Reply
Re: [SWDevil.Com] How to display days since add and last modified In reply to
OOps, should be:

<%GT::Date::date_set_format("%yyyy%-%mm%-%dd%")%>

Not %dd%-%mm% :P

Try that and let me know if it works.

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] How to display days since add and last modified In reply to
Didn't worked.

Input
Code:
<%Signup_Date%> <br>

<%GT::Date::date_set_format("%yyyy%-%mm%-%dd%")%>
<%set _today = GT::Date::date_get%>
Since Signup: <%GT::Date::date_diff($Signup_Date,$_today)%>

Output
Code:
2008-08-09
0 Since Signup: -397

Vishal
-------------------------------------------------------
Quote Reply
Re: [SWDevil.Com] How to display days since add and last modified In reply to
Try printing this:

Signup: <%Signup_Date%>
Today: <%_today%>

..and let me know the output

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] How to display days since add and last modified In reply to
Here:

Input:
Code:
Signup: <%Signup_Date%> <br>
Today: <%_today%> <br>

Output
Code:
Signup: 2008-08-09
Today: Unknown Tag: '_today'

Vishal
-------------------------------------------------------
Quote Reply
Re: [SWDevil.Com] How to display days since add and last modified In reply to
Were you using that in conjunction with:


<%GT::Date::date_set_format("%yyyy%-%mm%-%dd%")%>
<%set _today = GT::Date::date_get%>

(i.e the code above first, then that other code I gave you)

Simply using those 2 lines I gave you won't work, as _today isn't defined)

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] How to display days since add and last modified In reply to
Okay.. now I updated the code and here it is:

Input
Code:
<%GT::Date::date_set_format("%yyyy%-%mm%-%dd%")%>
<%set _today = GT::Date::date_get%>

Signup: <%Signup_Date%> <br>
Today: <%_today%> <br>

Output
Code:
0 Signup: 2008-08-09
Today: 2009-09-10

Vishal
-------------------------------------------------------
Quote Reply
Re: [SWDevil.Com] How to display days since add and last modified In reply to
Is this on your dev server? If so, shoot me over the account you are testing it with - and I'll take a look. Can't be bothered to keep trying to debug it from the forum - much quicker just to do it myself ;)

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] How to display days since add and last modified In reply to
Check your pm.

Vishal
-------------------------------------------------------
Quote Reply
Re: [SWDevil.Com] How to display days since add and last modified In reply to
Should work now:

Code:
<%GT::Date::date_set_format("%yyyy%-%dd%-%mm%")%><br />
<%set _today = GT::Date::date_get()%><br />
TODAY: <%_today%> <br />
<%set tmp = $user.Signup_Date%><br />
Signup DAte: <%tmp%> <br />
Since Signup: <%GT::Date::date_diff($tmp,$_today)%><br />

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] How to display days since add and last modified In reply to
Sorry for the delayed reply, was out of town:

I just tried it again, however it does not seem to work.

Input
Code:
<%GT::Date::date_set_format("%yyyy%-%dd%-%mm%")%><br />
<%set _today = GT::Date::date_get()%><br />
TODAY: <%_today%> <br />
<%set tmp = $user.Signup_Date%><br />
Signup DAte: <%tmp%> <br />
Since Signup: <%GT::Date::date_diff($tmp,$_today)%><br />

Output
Code:
0

TODAY: 2009-15-09

Signup DAte: 2008-08-09
Since Signup: -372

Expected Output : Example
Code:
Since Signup: April 22, 2006 (3 years 4 months 18 days)

Vishal
-------------------------------------------------------
Quote Reply
Re: [SWDevil.Com] How to display days since add and last modified In reply to
Erm, how can you be expecting it to say years, even when its only been just over a year? (372 days, from the 15th of sept 2009, to the 8th sept 2008)

The reason you are getting a negative , just change this:

Code:
Since Signup: <%GT::Date::date_diff($tmp,$_today)%><br />

..to:
Code:
Since Signup: <%GT::Date::date_diff($_today,$tmp)%><br />

The rest is just fine =)

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] How to display days since add and last modified In reply to
Hey Andy,

This one worked :)
Code:
Since Signup: <%GT::Date::date_diff($_today,$tmp)%><br />

Andy wrote:
Erm, how can you be expecting it to say years, even when its only been just over a year? (372 days, from the 15th of sept 2009, to the 8th sept 2008)
I have not idea, on how that can be done, I was just hoping you would have some.

Here is a shot in the dark, do you think this is (or something like it) is possible:

Example:
Sign-up Date : April 8, 2008
Current Date : June 10, 2009

1. Since there is a different in year number (or more than 365 days, 366 for leap year), it can add 1 for year count there... if straight year number is used, than there would be no need to worry about leap year.
2. April 8, to May 7 = 1 month and till June 7 = 2 months.
3. June 7 to June 10 = 3 days.

So something like : Member Since: 1 Year 2 month & 3 days.

In addition, the output don't need to be in exact format.. Like (Date since last build global).. it can be output "signup_since_year", signup_since_month & "signup_since_days" separately. Which later can easily be used by admin within template.

Vishal
-------------------------------------------------------
Quote Reply
Re: [Andy] How to display days since add and last modified In reply to
Hi Andy,

Just realized that there is a much simpler solution (I think). How about using a simple age/birthdate counter type script. In addition, I did found a perfect script to generate the output.

So if we can simply break down Signup_Date (example 2009-09-15) like below it would solve the purpose, as simply inserting <%signup_year%>... etc can be inserted in javascript
signup_year = 2009
signup_month = 9
signup_day = 15

Here is how the code will work in javascript
Code:
var amonth = 9
var aday = 15
var ayear = 2009

Vishal
-------------------------------------------------------
Quote Reply
Re: [SWDevil.Com] How to display days since add and last modified In reply to
Just use:

split_date
Code:
sub {
my @tmp = split /-/, $_[0];
return {
ayear => $tmp[0],
amonth => $tmp[1],
aday => $tmp[2]
}
}

Then call with:

Code:
<%split_date($Signup_Date)%>

..and you should then have tags:

Code:
<%ayear%>
<%amonth%>
and
<%ayear%>

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] How to display days since add and last modified In reply to
It worked perfectly.. thanks :)

Vishal
-------------------------------------------------------