IF condition multiple parameters not working

Jackson Source

I have a plugin where a modal pops up during a particular time as per defined in the backend. If the user is browsing through the page and the modal is suppose to display say at 4:33pm then it will pop up. This is the basic concept.

This is my code :

<script type="text/javascript">
        day = [];
        timeu = [];
        msg = [];
        var time_zone = '<?php echo $text[0]->time_zone;?>';

    foreach ($text as $post) {
        <script type="text/javascript">
            day.push('<?php echo date("m/d/Y", strtotime($post->day));?>');
            timeu.push('<?php echo $post->timeset;?>');
            msg.push('<?php echo $post->textarea;?>')
    <script type="text/javascript">
            // var date = new Date().toLocaleString("en-US", {timeZone: time_zone});
            var date = new Date().toLocaleString("en-US", {timeZone: time_zone, timeZoneName: "short",hour12: false})
            // alert(date);
            var result = date.split(',');
            var date1 = result[0];
            // alert(date1);
            var time = result[1];
            var result1 = time.split(' ');
            var time1 = result1[1];

            for (var i = 0; i < 9; i++) { 
                if ((date1 == day[i]) && (time1 == timeu[i])) {
        }, 1000);

The values in date1 and day[i] , time1 & timeu[i] are coming as same when i alerted the values. so the string values are also same, but it dosent enter into the loop. i have tried using both"===" and "strcmp".Nothing Seems to Work. Can anyone provide me an insight?



comments powered by Disqus