Get filedate
-
I used to use
$dlm_download->get_the_file_date();
in my template to get date and time of file.
But it leads to fatal error in latest version of Download monitor.
Please, tell me correct code to get date and timestamp of file.
Thank you.
-
I want to get
Download title [size, format, timestamp]Here is my template
<?php /** * Shows filetype, title, filesize and date. */ if ( ! defined( 'ABSPATH' ) ) { exit; } // Exit if accessed directly /** @var DLM_Download $dlm_download */ ?> <a class="download-link filetype-icon <?php echo 'filetype-' . $dlm_download->get_version()->get_filetype(); ?>" title="<?php $dlm_download->the_title(); ?>" href="<?php $dlm_download->the_download_link(); ?>" rel="nofollow"> <?php $dlm_download->the_title(); ?></a> <text style="font-size : 70%;"><?php echo '[' ?><?php $dlm_download->get_version()->get_filesize_formatted(); ?><?php echo ',' ?> <?php $dlm_download->get_version()->get_filetype(); ?><?php echo ',' ?> <?php $dlm_download->get_version()->get_date(); ?><?php echo ']' ?> </text><br>
As result I got empty fields (except title).
Please, help me to fix code.-
This reply was modified 7 years, 2 months ago by
Roman Neverov.
here is result https://screenshots.firefox.com/j4K9fgv6bLpflG5b/np-oros.ru
Sorry for my mistake.
I forget aboutecho
I made some improvements, so now my template looks like<?php /** * Shows filetype, title, filesize and date. */ if ( ! defined( 'ABSPATH' ) ) { exit; } // Exit if accessed directly /** @var DLM_Download $dlm_download */ ?> <a class="download-link filetype-icon <?php echo 'filetype-' . $dlm_download->get_version()->get_filetype(); ?>" title="<?php $dlm_download->the_title(); ?>" href="<?php $dlm_download->the_download_link(); ?>" rel="nofollow"> <?php $dlm_download->the_title(); ?></a> <text style="font-size : 70%;"><?php echo '[' ?><?php echo $dlm_download->get_version()->get_filesize_formatted(); ?><?php echo ',' ?> <?php echo $dlm_download->get_version()->get_filetype(); ?><?php echo ',' ?> <?php get_option( 'date_format' ); echo $dlm_download->get_version()->get_date()->getTimestamp(); ?><?php echo ']' ?> </text><br>
result – https://screenshots.firefox.com/wAY03mI6lJ9Z4No3/np-oros.ru
and now its time to fix date format I think…-
This reply was modified 7 years, 2 months ago by
Roman Neverov.
I made some improvements
<?php /** * Shows filetype, title, filesize and date. */ if ( ! defined( 'ABSPATH' ) ) { exit; } // Exit if accessed directly /** @var DLM_Download $dlm_download */ ?> <a class="download-link filetype-icon <?php echo 'filetype-' . $dlm_download->get_version()->get_filetype(); ?>" title="<?php $dlm_download->the_title(); ?>" href="<?php $dlm_download->the_download_link(); ?>" rel="nofollow"> <?php $dlm_download->the_title(); ?></a> <text style="font-size : 70%;"><?php echo '[' ?><?php echo $dlm_download->get_version()->get_filesize_formatted(); ?><?php echo ',' ?> <?php echo $dlm_download->get_version()->get_filetype(); ?><?php echo ',' ?> <?php get_option( 'date_format' ); echo $dlm_download->get_version()->get_date()->getTimestamp(); ?><?php echo ']' ?> </text><br>
result – https://screenshots.firefox.com/wAY03mI6lJ9Z4No3/np-oros.ru
and now its time to fix date format I think…My final result (it works!)
<?php /** * Shows filetype, title, filesize and date. */ if ( ! defined( 'ABSPATH' ) ) { exit; } // Exit if accessed directly /** @var DLM_Download $dlm_download */ ?> <a class="download-link filetype-icon <?php echo 'filetype-' . $dlm_download->get_version()->get_filetype(); ?>" title="<?php $dlm_download->the_title(); ?>" href="<?php $dlm_download->the_download_link(); ?>" rel="nofollow"> <?php $dlm_download->the_title(); ?></a> <text style="font-size : 70%;"><?php echo '[' ?><?php echo $dlm_download->get_version()->get_filetype(); ?><?php echo ', ' ?><?php echo $dlm_download->get_version()->get_filesize_formatted(); ?><?php echo ', ' ?><?php echo date_i18n( get_option( 'date_format' ), $dlm_download->get_version()->get_date()->getTimestamp() ); ?><?php echo ' в ' ?><?php echo date_i18n( get_option( 'time_format' ), $dlm_download->get_version()->get_date()->getTimestamp() ); ?><?php echo ']' ?> </text><br>
-
This reply was modified 7 years, 2 months ago by
- The topic ‘Get filedate’ is closed to new replies.