Products
GG网络技术分享 2025-03-18 16:12 12
So I have been trying to find a solution for this around 1 hour and I cant find the solution.
how do I update DATE with the update_post_meta() function?
I have ACF field which is jquery(date).
Ive triedupdate_post_meta($post_id,\'last_date\',$arr[9]);
when $arr[9]
is 22/09/2018like my Date format.
图片转代码服务由CSDN问答提供
感谢您的意见,我们尽快改进~
功能建议所以我一直试图找到一个解决方案大约1小时,我找不到解决方案。</ p >
如何使用update_post_meta()函数更新DATE?
我有ACF字段,即jquery(日期)。
我已经尝试</ p>
update_post_meta ($ post_id,\'last_date\',$ arr [9]); </ code> </ pre>
当 $ arr [9] </ code> 22时 / 09/2018 </ strong>
我的日期格式。</ p>
</ div>
网友观点:
For update_post_meta function it doesn\'t matter which kind of value you have. It stores it as a string. So the problem can\'t be related to $arr[9]\'s datetime format.
That\'s why there are only two options to check:
Write
echo $post_id;
before update_post_meta() function and check if it displays correct ID.
- Again, check your database wp_postmeta table and search for \\\"last_date\\\" field. May be it has some another prefix or postfix.
If to do these 2 steps, you will find the reason by 100%.
###
try like this, I think your date format is not correct:
$date_stamp = strtotime($arr[9]);$postdate = date(\\\"Y-m-d H:i:s\\\", $date_stamp);
update_post_meta($post_id,\'last_date\',$postdate);
Demand feedback