Get Smarty


Donate Bitcoin Bitcoin

Smarty Icon

You may use the Smarty logo according to the trademark notice.

Smarty Template Engine Smarty Template Engine

For sponsorship, advertising, news or other inquiries, contact us at:

Sites Using Smarty

Buy cheap glasses from and save up to 80%.

Where to buy prescription glasses? is your best choice!

Where to buy discount wedding dresses and cheap smart dresses free shipping -

Brautkleider auf

Buy New Arrival Cheap Prom Dresses 2015 at JDBRIDAL Prom Dress Store

Find Wedding Dresses Online at Canada from

Cheap bridesmaid dresses - rush delivery only 10 days delivery to Australia at

Wholesale Camping Equipment from China at



As a rule of thumb, always pass dates to Smarty as timestamps. This allows template designers to use the date_format modifier for full control over date formatting, and also makes it easy to compare dates if necessary.

Example 18.4. Using date_format



This will output:

Jan 4, 2009




This will output:



Dates can be compared in the template by timestamps with:

{if $order_date < $invoice_date} something..


When using {html_select_date} in a template, the programmer will most likely want to convert the output from the form back into timestamp format. Here is a function to help you with that.

Example 18.5. Converting form date elements back to a timestamp


// this assumes your form elements are named
// startDate_Day, startDate_Month, startDate_Year

$startDate = makeTimeStamp($startDate_Year, $startDate_Month, $startDate_Day);

function makeTimeStamp($year='', $month='', $day='')
   if(empty($year)) {
       $year = strftime('%Y');
   if(empty($month)) {
       $month = strftime('%m');
   if(empty($day)) {
       $day = strftime('%d');

   return mktime(0, 0, 0, $month, $day, $year);


See also {html_select_date}, {html_select_time}, date_format and $,

No comments for this page.
Post a Comment
All comments are moderated. Support questions are ignored, use the forums instead.
Email: (not shown)
What is 4 plus 12? (Are you human?)