PageRenderTime 43ms CodeModel.GetById 23ms RepoModel.GetById 0ms app.codeStats 0ms

/class/Plugin/Smarty/modifier.strftime.php

http://github.com/ethna/ethna
PHP | 27 lines | 8 code | 2 blank | 17 comment | 3 complexity | c36ceed6ab929b657eec22907e641c64 MD5 | raw file
Possible License(s): BSD-3-Clause
  1. <?php
  2. /**
  3. * smarty modifier:strftime()
  4. *
  5. * strftime()関数のwrapper
  6. *
  7. * sample:
  8. * <code>
  9. * {"2004/01/01 01:01:01"|strftime:"%Y年%m月%d日"}
  10. * </code>
  11. * <code>
  12. * 2004年01月01日
  13. * </code>
  14. *
  15. * @param string $string フォーマット対象文字列
  16. * @param string $format 書式指定文字列(strftime()関数参照)
  17. * @return string フォーマット済み文字列
  18. */
  19. function smarty_modifier_strftime($string, $format)
  20. {
  21. if ($string === "" || $string == null) {
  22. return "";
  23. }
  24. return strftime($format, strtotime($string));
  25. }