4 users online. Create an account or sign in to join them.Users
Get the current time
This is an open discussion with 11 replies, filed under Troubleshooting.
Search
I also needed this. I add the folowing to "symphony/lib/toolkit/class.frontendpage.php" around line 103:
'now' => DateTimeObj::get('Y-m-d H:i:s'),
'this-hour' => DateTimeObj::get('H'),
'this-minute' => DateTimeObj::get('i'),
'this-secoud' => DateTimeObj::get('s'),
'this-weekday' => DateTimeObj::get('w'),
Awesome! Thanks. :-)
Hi,
sorry im newbe in php and i tried to implement ur suggestion but got an php error
here class.frontendpage.php /** * Holds all the environment variables which include parameters set by * other Datasources or Events. * @var array */ private $_env = array( 'now' => DateTimeObj::get('H:i:s') );
and then the error i go in my frontend page
Parse error: syntax error, unexpected '(', expecting ')' in C:wampwwwuniversystemsymphonylibtoolkitclass.frontendpage.php on line 95
Any idea about what i do wrong
sorry, i insert the code again of my modification in class.frontendpage.php
private $_env = array(
'now' => DateTimeObj::get('H:i:s')
);
This thread is 3 years old already. Please create a new one next time. :-)
There's no need for custom PHP, especially hacking the core itself. Have a look at the EXSLT date:difference function and try something like
<xsl:value-of select="date:difference(concat(published-date,'T',published-date/@time,'Z'), concat($today, 'T', $current-time,'Z'))" />
@phoque - I don't get it. What is the advantage of starting a new thread when Fabien's issue strongly relates to this old thread?
I don't get it. What is the advantage of starting a new thread when Fabien's issue strongly relates to this old thread?
Outdated information. Hacking the core is a bad idea.
I wouldn't say that hacking the core is a bad idea, but I would say that it should only be done as a last resort. Many times I've found that hacking the core was the only way to get the results that I wanted.
You can now write an extension that subscribes to the FrontendParamsResolve delegate that can add parameters, without touching le core.
Are all the delegates in http://symphony-cms.com/learn/concepts/view/delegates/ accurate?
Nope, this documentation is outdated. Best use the list directly from the source code:
http://symphony-cms.com/learn/api/2.2/delegates/
There is an XSLT update pending that displays the above list more neatly.
Create an account or sign in to comment.
I'd like to be able to grab the current time to compare with an entry's post time so I can state how many hours ago it was posted. There are parameters for month, day and year so I can do this at a daily level, but no current time-stamp for an hourly.
Is there a way to do this in Symphony with a parameter I don't know about? I know XSLT 2.0 has a function for this, but my server is using XSLT 1.0.
Thanks!
P.S. It would be cool to be able to get the current weekday too. :-)