Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2009-02-28 10:00:33

Gallex
Member
Registered: 2006-10-08
Posts: 1,289

another time script

not sure what line exactly i need to uncomment to get it work…


//Depending on whether your page supports SSI (.shtml) or PHP (.php), UNCOMMENT the line below your page supports and COMMENT the one it does not:
//Default is that SSI method is uncommented, and PHP is commented:

var currenttime = '<!--#config timefmt="%B %d, %Y %H:%M:%S"--><!--#echo var="DATE_LOCAL" -->' //SSI method of getting server date
//var currenttime = '<? print date("F d, Y H:i:s", time())?>' //PHP method of getting server date

in default settings it displays: Current time undefined NaN, NaN NaN:NaN:NaN

Offline

#2 2009-02-28 10:21:53

jakob
Admin
From: Germany
Registered: 2005-01-20
Posts: 4,599
Website

Re: another time script

You need to write it like this for txp:

<txp:php>print date("F d, Y H:i:s", time());</txp:php>

The "F d, Y H:i:s" section determines how the time and date will be shown and you can change this format by changing the placeholders – e.g. just for hours, minutes, seconds use H:i:s". The placeholders are explained in the php docs on the date function.

Note that unlike the other script you posted, this does not update live.

Mary’s plugin upm_datetime provides a neat little wrapper for this, e.g. for the above, use:

<txp:upm_datetime function="date" format="F d, Y H:i:s"/>

TXP Builders – finely-crafted code, design and txp

Offline

#3 2009-02-28 11:04:21

Gallex
Member
Registered: 2006-10-08
Posts: 1,289

Re: another time script

thank’s jakob

Offline

Board footer

Powered by FluxBB