Saltar navegación

[Resuelto] Unix timestamp Format

This support ticket is created hace 2 años, 1 mes. 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 -

Supporter timezone: Asia/Kolkata (GMT+05:30)

Este tema contiene 8 respuestas, tiene 2 mensajes.

Última actualización por marcoR-6 hace 2 años, 1 mes.

Asistido por: Minesh.

Autor
Mensajes
#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
Supporter

Idiomas: Inglés (English )

Zona horaria: 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
Supporter

Idiomas: Inglés (English )

Zona horaria: Asia/Kolkata (GMT+05:30)

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
Supporter

Idiomas: Inglés (English )

Zona horaria: Asia/Kolkata (GMT+05:30)

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
Supporter

Idiomas: Inglés (English )

Zona horaria: Asia/Kolkata (GMT+05:30)

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

#2539731

My issue is resolved now. Thank you!