CiviCRM Community Forums (archive)

*

News:

Have a question about CiviCRM?
Get it answered quickly at the new
CiviCRM Stack Exchange Q+A site

This forum was archived on 25 November 2017. Learn more.
How to get involved.
What to do if you think you've found a bug.



  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion »
  • APIs and Hooks (Moderator: Donald Lobo) »
  • update a custom date field value
Pages: [1]

Author Topic: update a custom date field value  (Read 375 times)

rulley

  • I’m new here
  • *
  • Posts: 13
  • Karma: 1
  • CiviCRM version: 4.4.4
  • CMS version: Drupal
  • MySQL version: 5.5.25
  • PHP version: 5.4.4
update a custom date field value
February 11, 2014, 05:28:12 pm
hello trying to set a value for a custom date field... i am able to do it on text field but having some problems with date.. Any ideas? date format issues? thx
  if ($objectName == 'Individual' && $op == 'create') {
    $customId = 33;
    $customcreatedId = 31;
   
   
    $dt = gmdate("Y-m-d H:i:s", time());
    $customcreated = $dt;
    $custommodified = $dt;
    $customParams = array("entityID" => $objectId,  "custom_$customId" => 'test', "custom_$customcreatedId" => $dt);
    require_once '/Applications/MAMP/htdocs/ociadmin/sites/all/modules/civicrm/CRM/Core/BAO/CustomValueTable.php';
    CRM_Core_BAO_CustomValueTable::setValues( $customParams );
     

  }

rulley

  • I’m new here
  • *
  • Posts: 13
  • Karma: 1
  • CiviCRM version: 4.4.4
  • CMS version: Drupal
  • MySQL version: 5.5.25
  • PHP version: 5.4.4
Re: update a custom date field value
February 11, 2014, 09:36:31 pm
k figured it out.. the date time format is as follows.

$ts = time();
$date_to_save = date("YmdHis", $ts);

Erik Hommel

  • Forum Godess / God
  • I live on this forum
  • *****
  • Posts: 1773
  • Karma: 59
    • EE-atWork
  • CiviCRM version: all sorts
  • CMS version: Drupal
  • MySQL version: Ubuntu's latest LTS version
  • PHP version: Ubuntu's latest LTS version
Re: update a custom date field value
February 11, 2014, 11:37:10 pm
Thanks for sharing the solution as well :-)
Consultant/project manager at EEatWork and CiviCooP (http://www.civicoop.org/)

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion »
  • APIs and Hooks (Moderator: Donald Lobo) »
  • update a custom date field value

This forum was archived on 2017-11-26.