Title: Fix for is24Hours function
Last modified: October 18, 2021

---

# Fix for is24Hours function

 *  [jamal1wp](https://wordpress.org/support/users/jamal1wp/)
 * (@jamal1wp)
 * [4 years, 8 months ago](https://wordpress.org/support/topic/fix-for-is24hours-function/)
 * Asalam Alaikum,
 * I encountered an issue while uploading the CSV prayer times table, where valid
   times were flagged as invalid. I traced the issue to the is24Hours($row) function
   in validator.php in wp-content/plugins/daily-prayer-time-for-mosques/Models:
 * Below the modified code using preg_match():
 *     ```
       private function is24Hours($row)
           {
               $afternoonPrayers = array($row[6], $row[7], $row[8], $row[9], $row[10], $row[11], $row[12]);
   
               foreach($afternoonPrayers as $time) {
                  //  echo $time;   
                   if (!preg_match('#^([01]?[0-9]|2[0-3]):[0-5][0-9]?$#', $time))
                   {
                        echo "<h3 class='dptCenter ui-state-error'>$time is not in 24 hour time format for date: ". esc_html( $row[0] ) ."
                               </br> You must follow 24 hours time format, valid time format is <span class='green'>HH:MM</span></h3>";
                       return false;
                   }
   
                   /* old code */
                   /*
   
                   $firstPart = explode(':', $time);
                   if ($firstPart[0] !== '00' && (int)$firstPart[0] < 12) {
                       echo $firstPart[0] . $firstPart[1];
                       echo "<h3 class='dptCenter ui-state-error'>$time is not in 24 hour time format for date: ". esc_html( $row[0] ) ."
                               </br> You must follow 24 hours time format, valid time format is <span class='green'>HH:MM</span></h3>";
                       return false;
                   }
                   */
               }
   
               return true;
           }
       ```
   
 * Hope this helps!
    Jamal

Viewing 6 replies - 1 through 6 (of 6 total)

 *  Plugin Author [mmrs151](https://wordpress.org/support/users/mmrs151/)
 * (@mmrs151)
 * [4 years, 8 months ago](https://wordpress.org/support/topic/fix-for-is24hours-function/#post-14982143)
 * Walaikum Assalam wa rahmatullah my dear brother Jamal,
 * And jazakallahu khair for your time to help fixing issues within the plugin.
 * I make dua to have brothers like you, who can carry on this plugin after my death
   inshaaAllah.
 * Can you please send me your csv too so I can see the problem first and test it
   thoroughly.
 * Mustafiz.
 *  Thread Starter [jamal1wp](https://wordpress.org/support/users/jamal1wp/)
 * (@jamal1wp)
 * [4 years, 8 months ago](https://wordpress.org/support/topic/fix-for-is24hours-function/#post-14982202)
 * Asalam Alaikum Br. Mustafiz,
 * I sent you a sample CSV to **[mmrs151@gmail.com](https://wordpress.org/support/topic/fix-for-is24hours-function/mmrs151@gmail.com?output_format=md)**
 * JAK,
    Jamal
 *  Plugin Author [mmrs151](https://wordpress.org/support/users/mmrs151/)
 * (@mmrs151)
 * [4 years, 8 months ago](https://wordpress.org/support/topic/fix-for-is24hours-function/#post-14982488)
 * Jazakallah for that.
 * The csv worked in mine without any issues.
    I understand the improvement of your
   code. But could you please share with me what did not work on your csv with the
   previous code.
 * Duas
    Mustafiz.
 *  Thread Starter [jamal1wp](https://wordpress.org/support/users/jamal1wp/)
 * (@jamal1wp)
 * [4 years, 8 months ago](https://wordpress.org/support/topic/fix-for-is24hours-function/#post-14982719)
 * Asalam Alaikum,
 * It seems to be working now; I did not write exactly the time that it did not 
   verify correctly, but it was something like 10:30. It could have been an issue
   with WordPress and an update fixed it. Anyway, you are welcome to use the improved
   function which should work flawlessly and efficiently.
 * Jamal
    -  This reply was modified 4 years, 8 months ago by [jamal1wp](https://wordpress.org/support/users/jamal1wp/).
 *  Thread Starter [jamal1wp](https://wordpress.org/support/users/jamal1wp/)
 * (@jamal1wp)
 * [4 years, 8 months ago](https://wordpress.org/support/topic/fix-for-is24hours-function/#post-14982748)
 * Asalam Alaikum,
 * Actually, just now I got the validation message:
 * **10:29 is not in 24 hour time format for date: 1/1/2021
    You must follow 24 
   hours time format, valid time format is HH:MM
 * It failed on the the first line, 7th value:
 * “d_date”,”fajr_begins”,”fajr_jamah”,”sunrise”,”zuhr_begins”,”zuhr_jamah”,”asr_mithl_1″,”
   asr_mithl_2″,”asr_jamah”,”maghrib_begins”,”maghrib_jamah”,”isha_begins”,”isha_jamah”,”
   is_ramadan”,”hijri_date”
    “1/1/2021″,”23:58″,”00:23″,”01:00″,”07:04″,”12:30″,”
   10:29″,”15:00″,”15:00″,”13:07″,”13:12″,”14:09″,”19:45″,”0″,”0”
 * Jamal
 *  Plugin Author [mmrs151](https://wordpress.org/support/users/mmrs151/)
 * (@mmrs151)
 * [4 years, 8 months ago](https://wordpress.org/support/topic/fix-for-is24hours-function/#post-14985255)
 * Assalamualaikum dear brother Jamal,
 * I think there was a mistake in the csv, Asr mithl 1 can never be 10pm.
    I think
   I advised masjid who do not publish both Asr time to use same time for both Asr
   mithl, which was not the case in the csv.
 * As I also mentioned, your preg function works correctly just correctly too but
   your preg funciton should stop this csv with a validation error too.
 * Mustafiz.

Viewing 6 replies - 1 through 6 (of 6 total)

The topic ‘Fix for is24Hours function’ is closed to new replies.

 * ![](https://ps.w.org/daily-prayer-time-for-mosques/assets/icon-128x128.png?rev
   =1215663)
 * [Daily Prayer Time](https://wordpress.org/plugins/daily-prayer-time-for-mosques/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/daily-prayer-time-for-mosques/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/daily-prayer-time-for-mosques/)
 * [Active Topics](https://wordpress.org/support/plugin/daily-prayer-time-for-mosques/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/daily-prayer-time-for-mosques/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/daily-prayer-time-for-mosques/reviews/)

 * 6 replies
 * 2 participants
 * Last reply from: [mmrs151](https://wordpress.org/support/users/mmrs151/)
 * Last activity: [4 years, 8 months ago](https://wordpress.org/support/topic/fix-for-is24hours-function/#post-14985255)
 * Status: not resolved