[development] problem with custom date and timezones

Lluís enboig at gmail.com
Thu Jul 16 15:40:29 UTC 2009


I have created a custom node type. I have a date field which I created
as int in order to use it in views, being able to sort it, format,
etc....

My problem right now is that when inserting a node with one date, it
appears as "day before" when viewing the node. How should I save it to
avoid this problem?

My form looks like
  $arrayF=getdate(($node->data_paper>0 ? $node->data_paper : time()));
  $arrayF['month']=$arrayF['mon'];
  $arrayF['day']=$arrayF['mday'];
  $form['data_paper_array'] = array(
    '#type' => 'date',
    '#title' => 'Data Factura',
    '#default_value' => $arrayF,
    '#required' => TRUE,
    '#weight' => -9,
  );

My insert query looks like
  $dateF=$node->data_paper_array;
  $factura_tmsp=mktime(0,0,0,$dateF['month'],$dateF['day'],$dateF['year']);//
 $date['year']."-".$date['month']."-".$date['day'];
  $node->data_paper=$factura_tmsp;
  db_query("INSERT ......);

And my theme function:
  $output.="<li><b>Data Factura:</b>
".format_date($node->data_paper,'small')."</li>";


Any hint/advice? Thanks

-- 
*La vida és com una taronja, què esperes a exprimir-la?
*Si creus que l'educació és cara, prova la ignorància.
*La vida és com una moneda, la pots gastar en el que vulguis però
només una vegada.
*Abans d'imprimir aquest missatge, pensa en el medi ambient.


More information about the development mailing list