Jump to content

Bootstrapping Processwire: Date field outputs timestamp only


Recommended Posts

I am bootstrapping processwire in a php file for cronjob purposes.

Everything works fine, I can output all the data from fields that I like.

What confuses me: I have a datetime field. When displaying the field value in the bootstrapped file, I only get the timestamp of the selected date.

When displaying the same field value on a page inside of processwire the field value is a formatted date.

Can somebody explain to me why this is the case and to get around this (without date formatting).

Link to comment
Share on other sites

Hello @Stefanowitsch,

you get the unformatted value of the datetime field probably because output formatting is turned off when bootstraping ProcessWire.

You could try to temporarily turn it on and then turn it off again:

$page->of(true); // Turn output formatting on

echo $page->date; // Should be formatted

$page->of(false);  // Turn output formatting off again

But I would rather just format the date. 😉

Regards, Andreas

Link to comment
Share on other sites

5 minutes ago, AndZyk said:

Hello @Stefanowitsch,

you get the unformatted value of the datetime field probably because output formatting is turned off when bootstraping ProcessWire.

You could try to temporarily turn it on and then turn it off again:

$page->of(true); // Turn output formatting on

echo $page->date; // Should be formatted

$page->of(false);  // Turn output formatting off again

But I would rather just format the date. 😉

Regards, Andreas

Thanks! But this does not work unfortunately... 

However formatting the date like this was the workaround for me:

date("d.m.Y", $termin->startdatum)
  • Like 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...