KoolReport's Forum

Official Support Area, Q&As, Discussions, Suggestions and Bug reports.
Forum's Guidelines

How to convert timestamp / datetime to string? #3223

Open Jenni Yrjänä opened this topic on on Jan 5 - 3 comments

Jenni Yrjänä commented on Jan 5

Hello again!

I'm trying to display datetime / timestamp in a card. Is it so, that you can't display other than string or numbers in a card? Is there any options to display datetimes in a card?

This is the error I reseived:

Warning: number_format() expects parameter 1 to be double, string given in /var/www/html/cinetcampus/vendor/koolreport/core/src/core/Utility.php on line 148

Thanks in advance!

Sebastian Morales commented on Jan 8

You can try to format date data yourself and use ->raw(true) for your card:

$dateData = "2024-01-08";
$formattedDateString = date("d-m-Y", strtotime($dateData));
return $formattedDateString;
Jenni Yrjänä commented on Jan 9

I don't know how to work with that example you gave me.

Where I place "->raw(true)" (In setup function it gives fatal error message) ?

Where I place the other part of the code?

It would be easier to ask how do I display timestamp in a card?

What I want to do is to:

Fetch timestamp from database (this works fine) and pipe result to a card.

What I write and where I write it (example.php file or example.view.php file)?

Sebastian Morales commented on Jan 11

Oh sorry, did you use normal KoolReport reports or Dashboard framework and which widgets did you use?

Build Your Excellent Data Report

Let KoolReport help you to make great reports. It's free & open-source released under MIT license.

Download KoolReport View demo
help needed

None