Note that there are some explanatory texts on larger screens.

plurals
  1. POWhy doesn't php behave the same as when I explicitly set a value?
    primarykey
    data
    text
    <p>I have tried the same code both ways, it works the first way, when I do it the second way, it doesn't error, but just appears to do nothing.</p> <p>I'm getting some values (two dates) in a View in Drupal. I can print the values and get EXACTLY the same values as I have set explicitly. I've tested this using print.</p> <p>Although the values using print are identical to those i've set explicitly, it's not working with the data pulled from Drupal.</p> <p>Example of printing:</p> <pre><code>$fields['field_deal_from_value']-&gt;content; //The result from this is that it prints the following: 2011-04-24 </code></pre> <p><strong>Version 1 - Working with explicitly set value</strong></p> <pre><code>&lt;?php $pastDateStr = "2011-04-24"; $pastDateTS = strtotime($pastDateStr); for ($currentDateTS = $pastDateTS; $currentDateTS &lt;= strtotime("2011-05-28");$currentDateTS += (60 * 60 * 24)) { // use date() and $currentDateTS to format the dates in between $currentDateStr=date("d-m-Y",$currentDateTS); print $currentDateStr."&lt;br/&gt;"; } ?&gt; </code></pre> <p><strong>Version 2 - Not Working - Values are definitely set correctly</strong></p> <pre><code>&lt;?php $pastDateStr = $fields['field_deal_from_value']-&gt;content; $pastDateTS = strtotime($pastDateStr); for ($currentDateTS = $pastDateTS; $currentDateTS &lt;= strtotime($fields['field_deal_to_value']-&gt;content); $currentDateTS += (60 * 60 * 24)) { // use date() and $currentDateTS to format the dates in between $currentDateStr=date("d-m-Y",$currentDateTS); print $currentDateStr."&lt;br/&gt;"; } ?&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload