We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 50923
    • 137 Posts
    Iam trying to check server date and time to compate with date TV of resource, but i always get blank page when I try to check in IF statment, here is what i need.

    I have snippet lik this

    CheckCurrentDate
    <?php
    function getDatetimeNow() {
      $tz_object = new DateTimeZone('Europe/Belgrade');
      $datetime = new DateTime();
      $datetime->setTimezone($tz_object);
      return $datetime->format('Y\-m\-d\ h:i:s');
    }
    
    $currentDate = getDatetimeNow();
    
    $dtA = new DateTime($currentDate);
    $dtB = new DateTime($date);
    
    if ( $dtA > $dtB ) {
      $active = 0;
      return $active;
    }
    else {
      $active = 1;
      return $active;
    }


    But when on page if i try like this

    [[!CheckCurrentDate? &date=`[[*DatumIsteka]]`]]


    I got 1 or 0 based on TV value *DatumIsteka, all is working ok, but when i try to compare like this

    [[!If?
    	&subject=`[[!CheckCurrentDate? &date=`[[*DatumIsteka]]`]]`
    	&operator=`equals`
    	&operand=`0`
    	&then=`<script>
    	$("#tab3").html("<p>U Pripremi</p>");
    	</script>`
    	]]


    I got white page of resource??
    What can be the problem, any help will be nice smiley
      <a href="www.play2web.com" title="izrada web sajtova">Izrada web sajtova</a>
      • 48696
      • 41 Posts
      Hi, i've tried it, when were in resource two calls of snippet, there was a blank page. One snippet call is ok...

      
      [[-!CheckCurrentDate? &date=`[[*DatumIsteka]]`]]
      
      [[!If?
          &subject=`[[!CheckCurrentDate? &date=`[[*DatumIsteka]]`]]`
          &operator=`equals`
          &operand=`0`
          &then=`then`
          &else=`else`
          ]]
      
        • 4172
        • 5,888 Posts
        with two snippet - calls you try to declare the same funktion two times.

        use
        if (!function_exists('getDatetimeNow')){ }
        to check, if the function allready exists.
          -------------------------------

          you can buy me a beer, if you like MIGX

          http://webcmsolutions.de/migx.html

          Thanks!