Navigation überspringen

[Gelöst] Unix timestamp Format

This support ticket is created vor 3 years, 7 months. 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.

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

Zeitzone des Unterstützers: Asia/Kolkata (GMT+05:30)

Dieses Thema enthält 8 Antworten, hat 2 Stimmen.

Zuletzt aktualisiert von marcoR-6 vor 3 years, 6 months.

Assistiert von: Minesh.

Author
Artikel
#2537057

hi,

I have a costum date field that I need to format

this is my code:
$end_date = get_post_meta( $course_id, 'wpcf-end_date', true );
$end_format = date ('j F Y', $end_date);

Everything works fine but I have this error log:
warning date() expects parameter 2 to be int string given

I saw from this topic that you recommended the same method https://toolset.com/forums/topic/unix-timestamp-change/

How to fix?

#2537681

Minesh
Unterstützer

Sprachen: Englisch (English )

Zeitzone: Asia/Kolkata (GMT+05:30)

Hello. Thank you for contacting the Toolset support.

Can you please try to use the following line of code and replace with your existing line:

$end_format = date ('j F Y',(int)$end_date);

does that helps to fix the issue?

#2537751

Hi, thanks for the reply. I had evaluated this solution but in case there were 0 (highly unlikely but it can be) in the first positions in the timestamp it would be removed

#2537777

Minesh
Unterstützer

Do you mean that when there is leading 0 with the value - the field is not displayed?

#2537787

No, i mean something link this:

$end_date = get_post_meta( $course_id, 'wpcf-end_date', true ); -> for example "0674124393"
$end_format = (int)$end_date; -> results : 674124393

#2537805

Minesh
Unterstützer

We are casing the variable with integer. What is the issue you are having I'm not getting. Also, this is not related to Toolset but something related to PHP.

#2537807

Hello,

is it correct that I take this meta data as a string?
$end_date = get_post_meta( $course_id, 'wpcf-end_date', true );
is generated with a costum date field

#2537837

Minesh
Unterstützer

Yes - you can as Toolset stores the custom date field value as Unix Timestamp.

#2539731

My issue is resolved now. Thank you!