Hi, i am searching for a date format in Gallerz

Have a question or a suggestion about a 3rd party addon module or plugin?
Let us know here.
Locked
janvl
Power Poster
Power Poster
Posts: 985
Joined: Wed Aug 13, 2008 10:57 am

Hi, i am searching for a date format in Gallerz

Post by janvl »

I want $image->filedate
to give me the unix timestamp.

I cannot find why I always get a formatted date/time.
How do I force a timestamp?

Regards,
Jan
HarmO
Power Poster
Power Poster
Posts: 251
Joined: Thu Jan 26, 2012 3:22 pm

Re: Hi, i am searching for a date format in Gallerz

Post by HarmO »

Try {$image->filedate|date_format:"%s"}
this should convert in to a unix timestamp.

for more info watch smarty or php website
https://www.smarty.net/docsv2/en/langua ... format.tpl

http://php.net/strftime
Kind regards,
HarmO
janvl
Power Poster
Power Poster
Posts: 985
Joined: Wed Aug 13, 2008 10:57 am

Re: Hi, i am searching for a date format in Gallerz

Post by janvl »

Thank you,

i must have overseen that, i searched on both links before.

what i do is check the date-difference with smartynow and when the image is older then 3 month it is marked "older image".

I changed the template to (example)

Code: Select all

{math equation="x - y" x=$smarty.now y=($image->filedate|date_format:"%s") assign="difr"}
{if $difr > 600} oud {else} {$image->filedate}{/if}
Now it is working.

Regards,
Jan
HarmO
Power Poster
Power Poster
Posts: 251
Joined: Thu Jan 26, 2012 3:22 pm

Re: Hi, i am searching for a date format in Gallerz

Post by HarmO »

your welcome
Kind regards,
HarmO
User avatar
PinkElephant
Forum Members
Forum Members
Posts: 173
Joined: Fri Feb 06, 2009 2:08 pm

Re: Hi, i am searching for a date format in Gallerz

Post by PinkElephant »

Hi Jan
janvl wrote:

Code: Select all

{math equation="x - y" x=$smarty.now y=($image->filedate|date_format:"%s") assign="difr"}
{if $difr > 600} oud {else} {$image->filedate}{/if}
Just a minor observation... the smarty docs warn about math being expensive (due to eval) so raw date arithmetic may be a better option. Untested, something like...

Code: Select all

{* image unix timestamp (seconds since 1970-01-01) *}
{image_timestamp = $image->filedate|date_format:"%s"}

{* image age in seconds *}
{image_age = $image_timestamp - $smarty.now}

{* 90 days: 90 * 24*60*60 = 7776000 seconds *}
{if $image_age <= 7776000} 
	newer
{else} 
	older
{/else}
Also, it won't require setting permissive_smarty true.
janvl
Power Poster
Power Poster
Posts: 985
Joined: Wed Aug 13, 2008 10:57 am

Re: Hi, i am searching for a date format in Gallerz

Post by janvl »

Thanks PinkElephant

I will change it, but I have had no problem using math, the customer has a vserver with more then enough resources to run all his sites, 5 times CMSMS and some other webapps.

I am busy modernising his installations after I was asked to take over the job.

Regards,
Jan
Locked

Return to “Modules/Add-Ons”