バージョン選択

フォーラム

メニュー

オンライン状況

69 人のユーザが現在オンラインです。 (54 人のユーザが フォーラム を参照しています。)
登録ユーザ: 0
ゲスト: 69
もっと...

サイト内検索

質問 > フロント機能 > 月曜日のみを取得するSmartyスクリプトの作成

フロント機能

新規スレッドを追加する

スレッド表示 | 新しいものから 前のトピック | 次のトピック | 下へ
投稿者 スレッド
manabubb
投稿日時: 2014/4/16 19:46
対応状況: −−−
半人前
登録日: 2014/4/15
居住地:
投稿: 12
月曜日のみを取得するSmartyスクリプトの作成
こんにちは。

月曜日のみを取得するSmartyスクリプトの作成を作成したいと思っております。
調べつつやってみたところ、以下のスクリプトまでは作ることができました。

■機能
・現在日時の取得
・7日おきに日付の出力


<select>
        <option value="--" selected="selected">--年--月--日</option>
            <!--{section name=time start=$smarty.now loop=$smarty.now+25920000 step=604800}-->
            <option value="{$smarty.section.time.index|date_format:"20%y年 %m月 %d日"}">
            <!--{$smarty.section.time.index|date_format:"20%y年 %m月 %d日"}-->
        </option>
        <!--{/section}-->
</select>


■改善したいこと
上記スクリプトでは、現在日時を取得した後に、7日おきに日付を出力しています。
現在日時ではなく、翌週の月曜日を取得した上で、7日おきに日付を出力することは可能でしょうか?

尚、利用しているECCUBEの環境は以下のとおりです。


EC-CUBE	 2.13.1
サーバーOS	 Linux mba-cebu.asia 2.6.18-028stab056 #1 SMP Mon Nov 2 13:19:07 UTC 2009 i686
DBサーバー	 PostgreSQL 8.4.8
WEBサーバー	 Apache/2.0.64 (Unix)
PHP	 5.3.15 (Core, date, ereg, libxml, pcre, filter, Reflection, SPL, hash, apache2handler, SimpleXML, xml, session, iconv, sqlite3, ctype, curl, dom, gd, gettext, standard, json, mbstring, mcrypt, mysql, mysqli, openssl, PDO, pdo_mysql, pgsql, sockets, zip, zlib, mhash, ionCube Loader)
GD	 有効 (GD Version => bundled (2.0.34 compatible), FreeType Support => 1, FreeType Linkage => with freetype, T1Lib Support => 1, GIF Read Support => 1, GIF Create Support => 1, JPEG Support => 1, PNG Support => 1, WBMP Support => 1, XPM Support => 1, XBM Support => 1, JIS-mapped Japanese Font Support => 1)
HTTPユーザーエージェント	 Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/34.0.1847.116 Safari/537.36
PHP情報


ご教授いただけますと幸いです。
どうぞよろしくお願いいたします。
yuh
投稿日時: 2014/4/17 10:50
対応状況: −−−
登録日: 2013/1/9
居住地: 大阪
投稿: 1819
Re: 月曜日のみを取得するSmartyスクリプトの作成

<!--{assign var=today value=$smarty.now|date_format:"%w"}-->
<!--{if $today != 1}-->
	<!--{math equation="`$smarty.now` + (8 - $today) * 60 * 60 * 24" assign="startday"}-->
<!--{else}-->
	<!--{math equation="`$smarty.now` + $today * 60 * 60 * 24 * 7" assign="startday"}-->
<!--{/if}-->
<br clear="all">
<select>
        <option value="--" selected="selected">--年--月--日</option>
            <!--{section name=time start=$startday loop=$smarty.now+25920000 step=604800}-->
            <option value="{$smarty.section.time.index|date_format:"20%y年 %m月 %d日"}">
            <!--{$smarty.section.time.index|date_format:"20%y年 %m月 %d日"}-->
        </option>
        <!--{/section}-->
</select>


こんな感じですか?
manabubb
投稿日時: 2014/4/18 14:44
対応状況: −−−
半人前
登録日: 2014/4/15
居住地:
投稿: 12
Re: 月曜日のみを取得するSmartyスクリプトの作成
ありがとうございます!!
無事に動かすことができました。

ぼくは、%W の意味がわからずにググったので、今後にこの記事を見る人向けに%Wの定義を貼っておきます。
// %W - 現在の年で何番目の週であるかを10進数で表現。 年間で最初の月曜を最初の週の最初の日として数えます。
スレッド表示 | 新しいものから 前のトピック | 次のトピック | トップ


 



ログイン


EC-CUBE公式 Amazon Payプラグイン

統計情報

総メンバー数は88,850名です
総投稿数は109,986件です

投稿数ランキング

1
seasoft
7367
2
468
3217
3
AMUAMU
2712
4
nanasess
2313
5
umebius
2085
6
yuh
1819
7
h_tanaka
1646
8
red
1570
9
mcontact
1291
10
tsuji
958
11
fukap
907
12
shutta
835
13
tao_s
799
14 ramrun 789
15 karin 689
16 sumida 641
17
homan
633
18 DELIGHT 572
19
patapata
502
20
flealog
485


ネットショップの壺

EC-CUBEインテグレートパートナー

Copyright© EC-CUBE CO.,LTD. All Rights Reserved.