• twitter image
  • facebook image
  • youtube image
  • linkedin image
Language: CMS Made Simple Czech CMS Made Simple France CMS Made Simple Spain CMS Made Simple Hungary CMS Made Simple Russia CMS Made Simple Netherlands

All times are UTC




Post new topic Reply to topic  [ 7 posts ] 
Author Message
 Post subject: Ako pridať 1 hodinu casu?
PostPosted: Fri Feb 15, 2013 10:13 pm 
Offline
Forum Members
Forum Members

Joined: Wed Mar 16, 2011 9:13 am
Posts: 198
zdravim

vystupom {$cas|date_format:'%-H:%M'} su hodnoty napr. 16:30, 10:00 atd
potrebujem ale k $cas priratat 1 hodinu (teda vystup by bol 17:30, 11:00 atd)

ako na to?


Top
 Profile  
 
 Post subject: Re: Ako pridať 1 hodinu casu?
PostPosted: Wed Feb 20, 2013 4:52 pm 
Offline
Forum Members
Forum Members

Joined: Mon Sep 10, 2007 1:58 pm
Posts: 66
Location: Pardubice
nezkoušel si {$cas+1|date_format:'%-H:%M'} ? bylo by to takové přímočaré řešení hodné php
nebo místo $cas
date_add($cas, date_interval_create_from_date_string('1 hour'))


Top
 Profile  
 
 Post subject: Re: Ako pridať 1 hodinu casu?
PostPosted: Thu Feb 21, 2013 8:19 pm 
Offline
Power Poster
Power Poster
User avatar

Joined: Tue Oct 10, 2006 5:00 pm
Posts: 440
Location: Bratislava
Cez uzivatelsky tag: http://chod.sk/aztw3


Top
 Profile  
 
 Post subject: Re: Ako pridať 1 hodinu casu?
PostPosted: Sat Feb 23, 2013 10:58 pm 
Offline
Forum Members
Forum Members

Joined: Wed Mar 16, 2011 9:13 am
Posts: 198
kuzmany wrote:
Cez uzivatelsky tag: http://chod.sk/aztw3


takze sa to da len cez UDT?

ako ale? neviem ako to mam spravit (assignovat do smarty) kedze pri $cas je toto {$cas['@attributes']['zaciatok']}


Top
 Profile  
 
 Post subject: Re: Ako pridať 1 hodinu casu?
PostPosted: Sun Feb 24, 2013 8:48 am 
Offline
Forum Members
Forum Members

Joined: Mon Sep 10, 2007 1:58 pm
Posts: 66
Location: Pardubice
není to třeba, ve smarty šabloně napíšeš blok

{php}
jakýkoliv php kód, který se při parsování šablony vykoná
např. $cas = date($cas, strtotime ("+1 hour"));
{/php}

a v něm si můžeš s proměnou $cas dělat co se ti zlíbí, viz funkce pro práci s čase v php http://www.php.net/manual/en/function.time.php
funkce, které by ti mohly vyhovovat jsou strtotime http://php.net/strtotime a date_add http://www.php.net/manual/en/function.date-add.php


Top
 Profile  
 
 Post subject: Re: Ako pridať 1 hodinu casu?
PostPosted: Sun Feb 24, 2013 2:26 pm 
Offline
Forum Members
Forum Members

Joined: Wed Mar 16, 2011 9:13 am
Posts: 198
bunak wrote:
není to třeba, ve smarty šabloně napíšeš blok

{php}
jakýkoliv php kód, který se při parsování šablony vykoná
např. $cas = date($cas, strtotime ("+1 hour"));
{/php}


diky a mozes mi napisat ako by to malo vyzerat nakolko niesom v php zdatny (pokusal som sa to cez udt ale ako si mi to nefungovalo)
moja premenna je {$cas['@attributes']['zaciatok']|date_format:'%-H:%M'}

nasiel som aj nieco taketo lenze neviem ako to mam aplikovat
Code:
{"+1 hour"|date_format:"%H:%M:%S"}

http://www.smarty.net/forums/viewtopic.php?t=4476&sid=2f51c9d6364784a95b4754bed1f58390


Top
 Profile  
 
 Post subject: Re: Ako pridať 1 hodinu casu?
PostPosted: Sun Feb 24, 2013 9:13 pm 
Offline
Power Poster
Power Poster
User avatar

Joined: Tue Oct 10, 2006 5:00 pm
Posts: 440
Location: Bratislava
Vytvor UDT posun_cas. Je to pisane z hlavy:

Code:
$smarty = cmsms()->GetSmarty();

if(!isset($params['mojcas']))
return;
$cas = $params['mojcas'];

$format =  'Y-m-d H:i:s';
if(isset($params['format']))
$format = $params['format'];

$posun = 3600;
if(isset($params['posun']))
$posun= $params['posun'];

$novy_cas =  date($format, strtotime($cas) + $posun);

if(isset($params['assign']))
$smarty->assign($params['assign'], $novy_cas);

return  $novy_cas;


Pouzitie:

Code:
{posun_cas mojcas=$cas format='H:M' posun=3600}


Pricom premenna posun je v sekundach.

Kurva chalani, ale toto su uplne zaklady...


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 7 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users


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 post attachments in this forum

Search for:
Jump to:  
A2 Hosting