|
Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon. |
|
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 |
|
Juliano Smarty n00b
Joined: 20 Apr 2014 Posts: 1
|
Posted: Sun Apr 20, 2014 10:20 pm Post subject: merci |
|
|
Salut mec, j'ai 5 ans de retard sur ta réponse et tu verra sûrement jamais la mienne mais merci infiniment sa faisait des semaines que je cherchais ce code !
Encore merci |
|
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
|