Skip Navigation

[Resolved] Trouble storing a timestamp in a date field

This support ticket is created 3 years ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Hong_Kong (GMT+08:00)

This topic contains 1 reply, has 2 voices.

Last updated by Luo Yang 3 years ago.

Assisted by: Luo Yang.

Author
Posts
#2208077

Tell us what you are trying to do?
I am trying to store the current date and time in a date field.

I'm using the following shortcode to get the timestamp.

add_shortcode('wpv-post-today', 'today_shortcode');
function today_shortcode() {
  return time();
}

I have been able to confirm this shortcode is generating the proper timestamp.

Here's how I'm saving the timestamp in the date field.

[cred_field scaffold_field_id='submission-date' field='submission-date' force_type='field' class='form-control' output='bootstrap' value='[wpv-post-today]']

When I display the raw value of the submission-date field I see a different value than the timestamp that was generated by the shortcode. As an example. When the shortcode generated timestamp of 1635431592 the submission-date field stored a value of 1635379200 which is the same date but 12:00am instead of 2:33:12 PM.

I cannot figure out why it's not storing the correct timestamp.

#2208645

Hello,

please try these:
1) Dashboard-> Toolset-> Custom fields, find and edit the custom field group, find and edit the custom field "submission-date", enable option "Input date and time"

2) Modify your custom PHP codes as below:

add_shortcode('wpv-post-today', 'today_shortcode');
function today_shortcode() {
  return current_time('timestamp');
}

And test again