Get Smarty

Donate

Donate Bitcoin Bitcoin
Paypal

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 eyeglasses from Cheapglasses123.com and save up to 80%.

Buy prescription glasses from www.australiaglasses.com and save.

Cheap Glasses Now On Sale at GlassesPeople.com. Starts At $7.95.

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

Brautkleider auf Topwedding.de

Find free files to download on allwhatyouwant.net

Looking For Affordable Wedding Dresses 2015 at Best Prices On TDBridal.com

Shop high quality cheap prom dresses on Dresswe.co.uk

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

Advertisement

日期时间

一般�验而言,都是将时间戳作为日期时间值传递给Smarty。 模�设计者�以使用date_format 修饰器�控制日期时间的显示格�,还�以在需�时进行日期的比较。

Example 21.4. 使用 date_format


{$startDate|date_format}

    

输出:


Jan 4, 2009

    

{$startDate|date_format:"%Y/%m/%d"}

    

输出:


2009/01/04

    

日期的时间戳�以在模�内进行比较:


{if $order_date < $invoice_date}
   ...do something..
{/if}

    

当在模�内使用 {html_select_date}, 程�设计者会希望将输出的日期转�回时间戳。下�的函数�以�到这点:

Example 21.5. 转�元件的日期为时间戳


<?php

// 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);
}
?>

    

�� {html_select_date}, {html_select_time}, date_format 和 $smarty.now,

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

Advertisement