Jump to content

Warning: date() expects parameter 2 to be long...


Recommended Posts

Hi!
I need some help with PHP.

A few days ago I installed the plugin into Wordpress.

Everything worked, but today an error occurred.

Warning: date() expects parameter 2 to be long, string given in /home/wp-content/plugins/upcoming-events-lists/upcoming-events-lists.php on line 211

 

Line 210 and 211:

$start_date = get_post_meta( $post_id, 'event-start-date', true );
echo date( 'F d, Y', $start_date );

Can somebody be so kind as to tell me what I need to change to resolve this?

I need to fix this ASAP ;/ 

Thanks.

 

The date() function expects a Unix timestamp (i. e. an integer) as the second parameter. See the PHP manual.

 

Your $start_date is appearently not a Unix timestamp. It may be a MySQL DATE which must be parsed before it can be converted. There may be a WordPress function for it. Otherwise you'll have to parse the date yourself and then reformat it.

<?php

const MYSQL_DATE_FORMAT = 'Y-m-d';



$input = '2016-08-30';
echo DateTime::createFromFormat(MYSQL_DATE_FORMAT, $input)->format('F d, Y');
  • Like 1
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.