Unable to set date field programmatically Somehow my custom fields ('datum' and 'high') are not set in the following script. Could someone tell me what I am doing wrong?

    function erstelle_kursenodes() {

$content = file_get_contents('http://www.xmlcharts.com/cache/precious-metals.php?format=json');

if(empty($content)){
    echo 'KEINE API-VERBINDUNG';
} else {
$cuobj = json_decode($content);
  // add node properties
  $newNode = (object) NULL;
  $newNode-&gt;type = 'kurs';
  $newNode-&gt;title = 'XAUUSD';
  $newNode-&gt;uid = 0;
  $newNode-&gt;created = strtotime("now");
  $newNode-&gt;changed = strtotime("now");
  $newNode-&gt;status = 1;
  $newNode-&gt;comment = 0;
  $newNode-&gt;promote = 0;
  $newNode-&gt;moderate = 0;
  $newNode-&gt;sticky = 0;
  // add fields
  $newNode-&gt;field_datum[$node-&gt;language][0]['value'] = date('Y-m-d h:i:s', strtotime("now"));
  $newNode-&gt;field_high[$node-&gt;language][0]['value'] = number_format($cuobj-&gt;usd-&gt;gold * 31.1034768, 2, '.', '');
  // save node
  node_save($newNode);
}}


'datum' is a regular date field

'high' is decimal integer with two digits after a point
It is a format issue that you are choosing to save.

    $newNode-&gt;field_datum['und'][0]['value'] = date('Y-m-d h:i:s', strtotime("now"));
//Here in place $node-&gt;language pass 'und' and then try.
//Just save a node directly from backend, let say it is saved with node id 10.

$nid = 10;
echo "&lt;pre&gt;";
print_r(node_load($nid)) ;
echo "&lt;/pre&gt;";


Now check which format it is using to save. Pass same format once statically and then make it dynamic. Hopefully it will resolve your issue.