 |
Smarty
The discussions here are for Smarty, a template engine for the PHP programming language. Dedicated server web hosting provided by Guru-host.eu. |
| View previous topic :: View next topic |
| Author |
Message |
ausmarty Smarty n00b
Joined: 02 Sep 2009 Posts: 1
|
Posted: Wed Sep 02, 2009 1:43 pm Post subject: transformer le format d'une date timestamp |
|
|
Bonjour à tous.
Dans le fichier tpl de mon logiciel, j'ai
{issue.opened}
cela récupère l'heure dans la table au format timestamp.
Pour le mettre au format date j'ai mis:
{php}date('d m Y H:i',{issue.opened}){/php}
mais ça ne fonctionne pas. Pourriez vous m'aider svp.
Merci |
|
| Back to top |
|
leoz Smarty n00b
Joined: 02 Sep 2009 Posts: 1
|
Posted: Thu Sep 03, 2009 12:45 pm Post subject: |
|
|
Utilise la fonction mktime  |
|
| Back to top |
|
Gowser Smarty Pro

Joined: 19 Feb 2008 Posts: 104 Location: Nantes (France)
|
Posted: Thu Sep 10, 2009 2:08 pm Post subject: |
|
|
Bonjour,
Il y a 2 solutions pour ce problème :
La façon dégueulasse :
| Code: |
{assign var='dateConvert' value=$issue.opened}
{php}date('d m Y H:i', $this->get_template_vars('dateConvert')){/php}
|
La façon propre :
| Code: |
{$issue.opened|date_format:'%d %m %Y %H:%M'}
|
| Quote: |
date_format
Formate une date / heure au format strftime() donné. Les dates peuvent être passées à smarty en tant que timestamp unix, timestamp mysql ou comme chaîne quelconque contenant mois jour année (interprétable par strtotime()).
|
Voilou, ++ |
|
| Back to top |
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|