日期在Salesforce中的到达时间不同

问题描述

enter image description here

我正在使用drupal,并且我有一个Webform,其中有生产日期的字段,并且该字段中有日历当我在该字段中输入日期2020-09-30并提交表单时,保存该字段在Salesforce中这样错误地: 6/9/2022 更改为2022年,也更改了月份和日期

以下是我在salesforce函数中设置的条件

        function ublox_salesforce_salesforce_webforms_save_submission_alter(&$fields,$context) {
  foreach ($fields as $key => $value) {
    if (in_array($key,["Date_Prototype__c","Date_Production__c","NBIOT_Date_of_Field_Trial__c","NBIOT_Date_Lab_Trial__c"])) {
      $fields[$key] = trim($value);
      if ($fields[$key] == 'Date_Production__c') {
        $fields[$key] = format_date(strtotime($fields['Date_Production__c']),'medium','m-d-Y');
      }
  }

您可以看到我的'Date_production__c'条件(生产开始日期) 我在哪里做错了?我找不到任何可以帮助我的解决方案。

我还附上了我将日期设置为2020-09-30的字段的屏幕截图,但它的到达日期与 6/9/2022

enter image description here

不同

预先感谢

解决方法

format_date(strtotime($fields['Date_Production__c']),'medium','m-d-Y');的结果是什么,您可以将其写入日志或echo还是其他内容?

Salesforce API期望使用2020-09-14格式的日期(因此应该是Y-m-d?)和2020-09-14T18:07:30Z格式的日期时间。参见https://developer.salesforce.com/docs/atlas.en-us.soql_sosl.meta/soql_sosl/sforce_api_calls_soql_select_dateformats.htm