Adding time in php

Hi everyone

I’m trying to adjust the time of this widget for wordpress which is called Namaz Vakti. its a muslim prayer time widget you can check the widget page on this link https://wordpress.org/plugins/namaz-vakti/
There is also a github page for the widget at https://github.com/wp-plugins/namaz-vakti

There is a preview of the widget on the creators website which is http://www.erdemarslan.com/. if you look at the right sidebar you see the widget.

I’m using the widget on a local wordpress and its working fine without any problems.
i only need to know how i can adjust the time of the prayers. Like for example i want to add 30 minutes to the Fajir (imsak) prayer.

I did find this php file which is called widget.namazvakti.php and tried several things but without any luck.

[CODE]

        <div class="vakitler">
        
            <div id="imsak" class="vakit">
                <div class="vakit_adi"><?php _e('İmsak', 'namazvakti'); ?></div>
                <div class="vakit_saati"><?php echo $vakit['imsak']; ?></div>
            </div>
            
            <div id="gunes" class="vakit">
                <div class="vakit_adi"><?php _e('Güneş', 'namazvakti'); ?></div>
                <div class="vakit_saati"><?php echo $vakit['gunes']; ?></div>
            </div>
            
            <div id="ogle" class="vakit">
                <div class="vakit_adi"><?php _e('Öğle', 'namazvakti'); ?></div>
                <div class="vakit_saati"><?php echo $vakit['ogle']; ?></div>
            </div>
            
            <div id="ikindi" class="vakit">
                <div class="vakit_adi"><?php _e('İkindi', 'namazvakti'); ?></div>
                <div class="vakit_saati"><?php echo $vakit['ikindi']; ?></div>
            </div>
            
            <div id="aksam" class="vakit">
                <div class="vakit_adi"><?php _e('Akşam', 'namazvakti'); ?></div>
                <div class="vakit_saati"><?php echo $vakit['aksam']; ?></div>
            </div>
            
            <div id="yatsi" class="vakit">
                <div class="vakit_adi"><?php _e('Yatsı', 'namazvakti'); ?></div>
                <div class="vakit_saati"><?php echo $vakit['yatsi']; ?></div>
            </div>
            
            <div id="kible" class="vakit">
                <div class="vakit_adi"><?php _e('Kıble', 'namazvakti'); ?></div>
                <div class="vakit_saati"><?php echo $vakit['kiblesaati']; ?></div>
            </div>
        </div>
        </div>
    
    </div>
    <?php
    } else {
        echo 'İstenilen şehre ait veriler alınamadı!';
    }
    
    
    echo $after_widget;
}


private function hangi_vakitteyiz($vakitler)
{
    $imsak    = strtotime( date('d.m.Y') . ' ' . $vakitler['imsak'] . ':00');
    $gunes    = strtotime( date('d.m.Y') . ' ' . $vakitler['gunes'] . ':00');
    $ogle    = strtotime( date('d.m.Y') . ' ' . $vakitler['ogle'] . ':00');
    $ikindi    = strtotime( date('d.m.Y') . ' ' . $vakitler['ikindi'] . ':00');
    $aksam    = strtotime( date('d.m.Y') . ' ' . $vakitler['aksam'] . ':00');
    $yatsi    = strtotime( date('d.m.Y') . ' ' . $vakitler['yatsi'] . ':00');
    
    $simdi = strtotime(date('d.m.Y H:i:s'));
            
    if ($simdi > $yatsi)
    {
        return 'yatsi';
    }
    elseif ($simdi <= $yatsi AND $simdi > $aksam)
    {
        return 'aksam';
    }
    elseif ($simdi <= $aksam AND $simdi > $ikindi)
    {
        return 'ikindi';
    }
    elseif ($simdi <= $ikindi AND $simdi > $ogle)
    {
        return 'ogle';
    }
    elseif ($simdi <= $ogle AND $simdi > $gunes)
    {
        return 'gunes';
    } else {
        return 'imsak';
    }
    
}

private function hicri_dil_duzeltmesi($tarih)
{
    $exp = explode( ' ', $tarih );
    
    $hicri_ay = trim($exp[1]);
    
    return $exp[0] . ' ' . __($hicri_ay, 'namazvakti') . ' ' . $exp[2];
}

}[/CODE]

found this in the end of the php file.
i tried

$imsak = strtotime( date(‘d.m.Y’) . ’ ’ . $vakitler[‘imsak’] . ‘:00 + 30 minutes’);

But it looks like the time is not even being affected.

[CODE]

        <div class="vakitler">
        
            <div id="imsak" class="vakit">
                <div class="vakit_adi"><?php _e('İmsak', 'namazvakti'); ?></div>
                <div class="vakit_saati"><?php echo $vakit['imsak']; ?></div>
            </div>
            
            <div id="gunes" class="vakit">
                <div class="vakit_adi"><?php _e('Güneş', 'namazvakti'); ?></div>
                <div class="vakit_saati"><?php echo $vakit['gunes']; ?></div>
            </div>
            
            <div id="ogle" class="vakit">
                <div class="vakit_adi"><?php _e('Öğle', 'namazvakti'); ?></div>
                <div class="vakit_saati"><?php echo $vakit['ogle']; ?></div>
            </div>
            
            <div id="ikindi" class="vakit">
                <div class="vakit_adi"><?php _e('İkindi', 'namazvakti'); ?></div>
                <div class="vakit_saati"><?php echo $vakit['ikindi']; ?></div>
            </div>
            
            <div id="aksam" class="vakit">
                <div class="vakit_adi"><?php _e('Akşam', 'namazvakti'); ?></div>
                <div class="vakit_saati"><?php echo $vakit['aksam']; ?></div>
            </div>
            
            <div id="yatsi" class="vakit">
                <div class="vakit_adi"><?php _e('Yatsı', 'namazvakti'); ?></div>
                <div class="vakit_saati"><?php echo $vakit['yatsi']; ?></div>
            </div>
            
            <div id="kible" class="vakit">
                <div class="vakit_adi"><?php _e('Kıble', 'namazvakti'); ?></div>
                <div class="vakit_saati"><?php echo $vakit['kiblesaati']; ?></div>
            </div>
        </div>
        </div>
    
    </div>
    <?php
    } else {
        echo 'İstenilen şehre ait veriler alınamadı!';
    }
    
    
    echo $after_widget;
}


private function hangi_vakitteyiz($vakitler)
{
    $imsak    = strtotime( date('d.m.Y') . ' ' . $vakitler['imsak'] . ':00');
    $gunes    = strtotime( date('d.m.Y') . ' ' . $vakitler['gunes'] . ':00');
    $ogle    = strtotime( date('d.m.Y') . ' ' . $vakitler['ogle'] . ':00');
    $ikindi    = strtotime( date('d.m.Y') . ' ' . $vakitler['ikindi'] . ':00');
    $aksam    = strtotime( date('d.m.Y') . ' ' . $vakitler['aksam'] . ':00');
    $yatsi    = strtotime( date('d.m.Y') . ' ' . $vakitler['yatsi'] . ':00');
    
    $simdi = strtotime(date('d.m.Y H:i:s'));
            
    if ($simdi > $yatsi)
    {
        return 'yatsi';
    }
    elseif ($simdi <= $yatsi AND $simdi > $aksam)
    {
        return 'aksam';
    }
    elseif ($simdi <= $aksam AND $simdi > $ikindi)
    {
        return 'ikindi';
    }
    elseif ($simdi <= $ikindi AND $simdi > $ogle)
    {
        return 'ogle';
    }
    elseif ($simdi <= $ogle AND $simdi > $gunes)
    {
        return 'gunes';
    } else {
        return 'imsak';
    }
    
}

private function hicri_dil_duzeltmesi($tarih)
{
    $exp = explode( ' ', $tarih );
    
    $hicri_ay = trim($exp[1]);
    
    return $exp[0] . ' ' . __($hicri_ay, 'namazvakti') . ' ' . $exp[2];
}

}[/CODE]

Now i am not sure if i am editing the right file but if so please tell me which line of code i have to edit to add 30 minutes to the Imsak (fajir) prayer which is the first prayer in the table.
so all i want is a time offsets in minutes for each prayer time, in this case for the prayer Imsak (Fajir).

I also did emailed the creator of the widget a week ago but i have not received any mails back. The code is written in Turkish but there are still elemtns in the code in english.

Hope someone can help me out that would be great.

Thanks in advance

Hi mio510, welcome to the forum.

What does the $vakitler array return, numerics? if so can you simply do something like

' ' . ($vakitler['imsak'] + 30) . ':00'

thanks for the reply

i tried all the above but still no change in the time.
i think it’s a bit more difficult than i might think to change the time of this widget.
still no clue why the time is not being affected at all.

$vakitler array gets it times from http://www.diyanet.gov.tr/en/prayertime

when i insert the above code the whole website will output Parse error: syntax error, unexpected ‘$gunes’ (T_VARIABLE) in C:\xampp\htdocs\wordpress\wp-content\plugins\namaz-vakti\include\widget.namazvakti.php on line 227

i tried to add the code also like this

    $imsak  = strtotime( date('d.m.Y') . ' ' . $vakitler['imsak'] + 30 . ':00' 

but still the same result. site seems to stop working

one more question am i editing the right file?

I’m thinking it would likely be easier editing the file that creates the “time for” array.

I’ve downloaded the plugin and will look around in it ASAP.

One problem is all the non-Englsh. I rely on informative naming to get an idea of what’s what and will need to use strings that have no meaning to me.

Well, I’m afraid I’m at a loss.

I looked the the files for $vakitler but couldn’t obviossly see where it’s coming from.

The plugiin states it gets the info from http://www.diyanet.gov.tr/
The info might be coming from the ndb db files
ilceler sehirler ulkeler → ILC sehr they ulkeler
doesn’t mean anything I understand
Or it might be coming from an AJAX call, though I didn’t see an API at the gov site.

If the array is coming from AJAX I don’t see where, and changing what’s sent at the source would not be an option.

If the array is coming from the database it might be able to be changed with proper queries.

If you var_dump() $vakitler[‘imsak’] what is it?

While it’s all way more complex than I’m used to, I suspect it’s getting the times from this function:

private function al_vakitler( $ulke=NULL, $sehir=NULL, $ilce = NULL )

which is in the file namaz-vakti / include / class.namazvakti.php and seems to retrieve the times from the server you talked about. Without running the code it’s hard to see, but I think that’s where the array is built in the first place.

Can I ask why you want to change the times? That widget appears to support different locations and time zones, does that not handle the time difference?

I was thinking the same thing.
From what I could find (and there’s better than a good chance I’m wrong) Turkey does have different timezones, but they differ by hours not half-hours.

Hacking the class does seem likely the best option here, but unfortunately not being in English makes anything other than the English PHP difficult if not impossible for me to grok

hi Mittineague

no problem i know its a bit difficult to change the time. but could you help me out with this

I have installed the plugin wordpress.org/plugins/namaz-vakti/ but it seems this widget does not have any short code.
MY question how do i find the shortcode and if there is no short code how do i create a shortcode for this widget. i need the shortcode beacuse i will use the short code in a php file.

this is the widget github page in case you need to look at the files.

i have posted on the wordpres support forum but till now i have not received any replies or any solution.

thanks in advance

Usually if a shortcode is available, the plugin developer will include it in their documentation for the plugin. I can’t find any mention of it in their readme.txt file.

I have never myself added a shortcode to a plugin developed by someone else, and haven’t tested this, but you can create your own shortcodes for numerous other things in WordPress, so it would be worth a try.

Check out this tutorial: https://www.elegantthemes.com/blog/tips-tricks/how-to-create-shortcodes-in-wordpress

hi thanks for your reply

i did find this line in the namaz-vakti.php file

    // Widgetler için Shortcode desteği ekleyelim
    add_filter( 'widget_text', 'do_shortcode' );

anything i could try to make a shortcode for this widget .

From the WordPress Codex, the function of do_shortcode is “Search content for shortcodes and filter shortcodes through their hooks. If there are no shortcode tags defined, then the content will be returned without any filtering.”

Look this up in the Codex for more information. I would be very careful about changing the code of the plugin, though, to add a shortcode because it will be over-written in the next update of the plugin. Have you tried contacting the plugin developer directly to ask about this?

@mio510, I’ve moved this thread to the CMS & WordPress forum, because I think you might get a better response there.

thanks for moving the thread to the right forum.

im still waiting for someone to help me out with this because im new to wordpress i need a step by step explanation.
anyway i did contact the creator of the widget but it seems he has left the project and is not responding to any of my email or messages so i guess im not getting any help from the creator at this point.

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.