jreklund / php4dvd

php4dvd is an open source php/mysql powered movie database. Catalog your video collection with ease. Automatic update of information and images.
GNU General Public License v3.0
83 stars 43 forks source link

Change the date format #36

Closed Pajaura closed 6 years ago

Pajaura commented 6 years ago

Hello. I would like to change the format of the dates displayed (for example, those of loans) from the current YYYY-MM-DD to DD-MM-YYYY. I tried to change some parameters in the code but I was not successful. How can I do? TY

jreklund commented 6 years ago

You want to change it when you edit a movie/tv-series? Or just when you display the information.

jreklund commented 6 years ago

You can change the display template as follows. Everything else requires changes to the PHP-base or database; and is therefore not recommended.

https://github.com/jreklund/php4dvd/blob/master/tpl/default/movies/movie.html#L234

{$smarty.const.LOANED_OUT|htmlentities:3:'UTF-8'}{if $movie->loanname != ""} {$smarty.const.TO|htmlentities:3:'UTF-8'} {$movie->loanname|htmlentities:3:'UTF-8'}{/if}{if $movie->loandate != "0000-00-00"} {$smarty.const.ON|htmlentities:3:'UTF-8'} {$movie->loandate|date_format:"%d-%m-%Y"|htmlentities:3:'UTF-8'}{/if}
Pajaura commented 6 years ago

I need to change date format for the entire system, in edit mode and in visualization too. I have already try to change the code as you have suggest but nothing happend..

jreklund commented 6 years ago

The above code are only for the visual template. You may need to delete everything inside the folder compiled.

If you really need it changed you need to do the following: Create a custom jquery validation for your format for tpl\default\movies\javascript\update.html and tpl\default\movies\update.html Convert from your date format into ISO-date format YYYY-MM-DD before saving it in the database: in includes\movie.update.inc.php before line 93 Convert from ISO-date format YYYY-MM-DD into your format: in templates tpl\default\movie.html and update.html (same folder) OR convert it after it have been fetched in includes\movie.inc.php on line 45.