Hi, <br><br>I have same problem as here: <a href="http://drupal.org/node/1021466#comment-4766902">http://drupal.org/node/1021466#comment-4766902</a><br><br><a href="http://drupal.org/node/1021466#comment-4766902" class="active">Callbacks are only used by wrappers</a><br>
<div class="comment-heading">
<div class="submitted">Posted by <a href="http://drupal.org/user/892998" title="View user profile.">JvE</a> on <em>July 22, 2011 at 10:18am</em> </div>
</div>
<div class="content">
<div class="clear-block">
<p>Note that the "getter callback" and "setter callback" functions are <em>only</em> used by Entity metadata wrappers.<br>
Not by entity_load or Views and such.</p>
<p>You can not use these to convert a different timestamp format in a
database to a timestamp for use with the 'date' type unless you
specifically create a wrapper for each of your entity instances.</p>
<p>I tried to get my (int)yyyymmdd values from the database to show up
in Views as dates and mistakenly thought I could use the "getter
callback" for the transformation.<br>
Example of when callback is and is not used:<br></p><div class="codeblock"><code><span style="color:#0000bb"><?php<br> $entity </span><span style="color:#007700">= </span><span style="color:#0000bb">entity_load</span><span style="color:#007700">(</span><span style="color:#dd0000">'myentity'</span><span style="color:#007700">, array(</span><span style="color:#0000bb">1</span><span style="color:#007700">));<br>
print </span><span style="color:#0000bb">$entity</span><span style="color:#007700">-></span><span style="color:#0000bb">day</span><span style="color:#007700">; </span><span style="color:#ff8000">// this gives 20110721 (from the database)<br>
</span><span style="color:#0000bb">$item </span><span style="color:#007700">= </span><span style="color:#0000bb">entity_metadata_wrapper</span><span style="color:#007700">(</span><span style="color:#dd0000">'myentity'</span><span style="color:#007700">, </span><span style="color:#0000bb">$entity</span><span style="color:#007700">);<br>
print </span><span style="color:#0000bb">$item</span><span style="color:#007700">-></span><span style="color:#0000bb">day</span><span style="color:#007700">-></span><span style="color:#0000bb">value</span><span style="color:#007700">(); </span><span style="color:#ff8000">// this gives 1311206400 (from the "getter callback")<br>
</span><span style="color:#0000bb">?></span></code></div><br>
In Views my day shows up as "08/21/1970 - 19:18" ...<br>
so if someone can point me in the right direction to get my "days" as timestamps, I'm all ears. </div><div class="clear-block"><br></div><div class="clear-block"><br></div><div class="clear-block">How can i use "getter callback" to convert field from database stored as 'date' to timestamp for using for view? Or is there other way how to achieve this goal? </div>
<div class="clear-block"><br></div><div class="clear-block">Juraj</div></div><div><br></div>-- <br>Juraj Chlebec aka Havran<br><a href="http://www.svoji.sk">http://www.svoji.sk</a><br>