date - Getting last day of the current month -


i can last day in php using cal_days_in_month(cal_gregorian, 03, 2014); function , assign view. want know possible last day in current month using smarty date_format function? in advance

i'm not sure can solve using date_format function. wouldn't anyway, since put way application logic template.

but... if want anyway, add template function want.

php:

$tpl = new smarty(); $tpl->registerplugin("function","lastdayofmonth", "smarty_function_lastdayofmonth"); $tpl->display('your_template.tpl');  function smarty_function_lastdayofmonth($params, smarty_internal_template $template) {     return date("y-m-t", strtotime($params['date'])); } 

smarty:

{assign var='datevar' value='2014-03-06'} {lastdayofmonth date=$datevar} 

output:

2014-03-31 

keep in mind, easy example. there more 1 way use plugins within smarty.


Comments

Popular posts from this blog

c# - How to get the current UAC mode -

postgresql - Lazarus + Postgres: incomplete startup packet -

javascript - Ajax jqXHR.status==0 fix error -