Date format with strftime and multilanguage

I have been going through every post in every forum for the past 2 days and I can’t get the date system to work with Kirby. I want to display the dates differently for 2 languages, but somehow I can’t figure out how to change the date format from “%Y-%m-%d”. The date format I want to change is related to a file (not a page). Would that change anything? I have tried every way I could think of, but I keep getting the error:
Warning: strftime() expects parameter 2 to be long, object given
when I try to change the format, or else I don’t get any errors and it just prints out in the format “%Y-%m-%d”.

What am I doing wrong?!

I try to print out the day using for example:

<?php echo strftime('%d',$file->date()) ?>
-> Gives me the error.

<?php echo strftime($file->date()) ?>
-> No errors at all, just prints out in the unwanted format.

I have tried changing the format in my blueprints, even setting c::set('date.handler', 'strftime'); in my config file, nothing works. Pleease help!

The output from $page->date() and $file->date() differs. While $page->date()->value() return a UNIX timestamp, $file->date()->value() doesn’t.

This works:

<?php 
$date = strtotime($file->date());
$formattedDate = date('d.m.Y',$date);
echo $formattedDate;
?>

Oh my gosh, this is perfect, thank you very very much!

IMO, it would make more sense if the return value from both methods was the same, I have opened an issue on GitHub.

1 Like

Same here, I am looking through the docs trying to find where this is mentioned and haven’t found it yet. Indeed, I think it makes sense to have them both return the same value. Thank you for helping me out!

This is now fixed on the development branch.