Reports Screen Shows Current Month as Last Month Under Specific Circumstances

Helpdesk for my helpdesk software

Moderator: mkoch227

Post Reply
mkoch227
Posts: 666
Joined: Wed Jul 04, 2012 3:37 pm

Reports Screen Shows Current Month as Last Month Under Specific Circumstances

Post by mkoch227 »

This issue was originally reported on the Mods for HESK issue tracker (https://gitlab.com/mike-koch/Mods-for-HESK/issues/587); however it applies to HESK as well.

When viewing the reports page, "Last Month" will be the current month if you are accessing the page on the 31st day of the month and the previous month does not have 31 days (i.e. viewing the reports page on October 31st will show last month as October as PHP tries to get the month for 2017-09-31, which rolls over to 2017-10-01).

A possible solution would be to set the current date to the first of the month, and then use strtotime('last month').
Mike, Lead Developer of Image HESK: A surprisingly simple, user-friendly and FREE help desk software with integrated knowledgebase.
Klemen
Site Admin
Posts: 10145
Joined: Fri Feb 11, 2005 4:04 pm

Re: Reports Screen Shows Current Month as Last Month Under Specific Circumstances

Post by Klemen »

Thanks for the heads up.

It's a display issue only, the report date is then generated correctly. I will fix it by simply changing date('d') to 1 in the code:

Old:

Code: Select all

<option value="4" <?php echo $selected['time'][4]; ?>><?php echo $hesklang['r4']; ?> (<?php echo $hesklang['m'.date('n',mktime(0, 0, 0, date('m')-1, date('d'), date('Y')))]; ?>)</option>
New:

Code: Select all

<option value="4" <?php echo $selected['time'][4]; ?>><?php echo $hesklang['r4']; ?> (<?php echo $hesklang['m'.date('n',mktime(0, 0, 0, date('m')-1, 1, date('Y')))]; ?>)</option>
Same in export.php
Klemen, creator of HESK and PHPJunkyardWas this helpful? You can buy me a drink here Image

Image You should follow me on Twitter here

Help desk software | Cloud help desk | Guestbook | Link manager | Click counter | more PHP Scripts ...

Also browse for php hosting companies, read php books, find php resources and use webmaster tools
Post Reply