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

How to display days since add and last modified

(Page 2 of 2)
> >
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


IMPORTANT: I've now moved to ultranerds.co.uk, and the .com will no longer work!
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package (plugins total "value" $3,325 & rising, for just $350)| GLinks ULTRA Package PRO (plugins total "value" $5,625 & rising, for just $500)
Support Forum | Links SQL Plugins | DMOZ Dumps | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Compare our different Plugin packages *new* Free CSS Templates
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

-------------------------------------------------------
Web Hosting Kit: A to Z of Web Hosting! http://www.webhostingkit.com/
Software Devil: Software Search Made Easy! http://www.softwaredevil.com/
-------------------------------------------------------
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


IMPORTANT: I've now moved to ultranerds.co.uk, and the .com will no longer work!
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package (plugins total "value" $3,325 & rising, for just $350)| GLinks ULTRA Package PRO (plugins total "value" $5,625 & rising, for just $500)
Support Forum | Links SQL Plugins | DMOZ Dumps | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Compare our different Plugin packages *new* Free CSS Templates
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

-------------------------------------------------------
Web Hosting Kit: A to Z of Web Hosting! http://www.webhostingkit.com/
Software Devil: Software Search Made Easy! http://www.softwaredevil.com/
-------------------------------------------------------
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


IMPORTANT: I've now moved to ultranerds.co.uk, and the .com will no longer work!
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package (plugins total "value" $3,325 & rising, for just $350)| GLinks ULTRA Package PRO (plugins total "value" $5,625 & rising, for just $500)
Support Forum | Links SQL Plugins | DMOZ Dumps | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Compare our different Plugin packages *new* Free CSS Templates
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

-------------------------------------------------------
Web Hosting Kit: A to Z of Web Hosting! http://www.webhostingkit.com/
Software Devil: Software Search Made Easy! http://www.softwaredevil.com/
-------------------------------------------------------
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


IMPORTANT: I've now moved to ultranerds.co.uk, and the .com will no longer work!
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package (plugins total "value" $3,325 & rising, for just $350)| GLinks ULTRA Package PRO (plugins total "value" $5,625 & rising, for just $500)
Support Forum | Links SQL Plugins | DMOZ Dumps | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Compare our different Plugin packages *new* Free CSS Templates
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

-------------------------------------------------------
Web Hosting Kit: A to Z of Web Hosting! http://www.webhostingkit.com/
Software Devil: Software Search Made Easy! http://www.softwaredevil.com/
-------------------------------------------------------
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


IMPORTANT: I've now moved to ultranerds.co.uk, and the .com will no longer work!
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package (plugins total "value" $3,325 & rising, for just $350)| GLinks ULTRA Package PRO (plugins total "value" $5,625 & rising, for just $500)
Support Forum | Links SQL Plugins | DMOZ Dumps | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Compare our different Plugin packages *new* Free CSS Templates
Quote Reply
Re: [Andy] How to display days since add and last modified In reply to
Check your pm.

Vishal

-------------------------------------------------------
Web Hosting Kit: A to Z of Web Hosting! http://www.webhostingkit.com/
Software Devil: Software Search Made Easy! http://www.softwaredevil.com/
-------------------------------------------------------
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


IMPORTANT: I've now moved to ultranerds.co.uk, and the .com will no longer work!
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package (plugins total "value" $3,325 & rising, for just $350)| GLinks ULTRA Package PRO (plugins total "value" $5,625 & rising, for just $500)
Support Forum | Links SQL Plugins | DMOZ Dumps | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Compare our different Plugin packages *new* Free CSS Templates
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

-------------------------------------------------------
Web Hosting Kit: A to Z of Web Hosting! http://www.webhostingkit.com/
Software Devil: Software Search Made Easy! http://www.softwaredevil.com/
-------------------------------------------------------
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


IMPORTANT: I've now moved to ultranerds.co.uk, and the .com will no longer work!
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package (plugins total "value" $3,325 & rising, for just $350)| GLinks ULTRA Package PRO (plugins total "value" $5,625 & rising, for just $500)
Support Forum | Links SQL Plugins | DMOZ Dumps | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Compare our different Plugin packages *new* Free CSS Templates
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

-------------------------------------------------------
Web Hosting Kit: A to Z of Web Hosting! http://www.webhostingkit.com/
Software Devil: Software Search Made Easy! http://www.softwaredevil.com/
-------------------------------------------------------
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

-------------------------------------------------------
Web Hosting Kit: A to Z of Web Hosting! http://www.webhostingkit.com/
Software Devil: Software Search Made Easy! http://www.softwaredevil.com/
-------------------------------------------------------
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


IMPORTANT: I've now moved to ultranerds.co.uk, and the .com will no longer work!
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package (plugins total "value" $3,325 & rising, for just $350)| GLinks ULTRA Package PRO (plugins total "value" $5,625 & rising, for just $500)
Support Forum | Links SQL Plugins | DMOZ Dumps | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Compare our different Plugin packages *new* Free CSS Templates
Quote Reply
Re: [Andy] How to display days since add and last modified In reply to
It worked perfectly.. thanks :)

Vishal

-------------------------------------------------------
Web Hosting Kit: A to Z of Web Hosting! http://www.webhostingkit.com/
Software Devil: Software Search Made Easy! http://www.softwaredevil.com/
-------------------------------------------------------
> >