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
Hi, i am searching for a date format in Gallerz
Re: Hi, i am searching for a date format in Gallerz
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
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
HarmO
Re: Hi, i am searching for a date format in Gallerz
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)
Now it is working.
Regards,
Jan
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}Regards,
Jan
- PinkElephant
- Forum Members

- Posts: 173
- Joined: Fri Feb 06, 2009 2:08 pm
Re: Hi, i am searching for a date format in Gallerz
Hi Jan
Also, it won't require setting permissive_smarty true.
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...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}
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}
Re: Hi, i am searching for a date format in Gallerz
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
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
