Warning: date() expects parameter 2 to be long, string given in
date() expects a unix timestamp... I imagine you are passing it a date as a string.
e.g. 2010-10-10
You should use:
$this->expiry_date = date("m/d/Y", strtotime($rows['expiry_date']));
Or better yet, use the DateTime object.
$expiry_date = new DateTime($rows['expiry_date']);
$this->expiry_date = $expiry_date->format('m/d/Y');
Warning: date() expects parameter 2 to be long, string given
Your click_time
field probably is of type DATETIME
, and date()
expects the second parameter to be a timestamp (long
).
Try replacing line #2 with:
$click_time_to_date = new DateTime($mysql['click_time']);
Or make sure that your click_time
field is of type TIMESTAMP
.
Warning: date() expects parameter 2 to be long, object given in
The variable you supplied ($songs->PLAYEDAT
) is probably a string or at best a DateTime object.
If it's a DateTime object:
$songs->PLAYEDAT->format('Y-m-d H:i:s')
If it's a string representation of a date:
date('Y-m-d H:i:s', strtotime($songs->PLAYEDAT))
UPDATE: Answer specific to this question copied back from comment below
date('Y-m-d H:i:s', intval($songs->PLAYEDAT[0]))
Error: date() expects parameter 2 to be long, string given
Since 'day' is a column in mysql table, try
$this->db->where('DATE(day)', $datee);
Warning: date() expects parameter 2 to be long
Date expects parameter 2 to be a long. i.e. it expects a number to be returned.
You return a string (assuming) with get_post_meta
You need to convert it to a time first before you can return it (a date long)
Instead try
$day = date("l, F jS", strtotime(get_post_meta($post->ID, 'date_value', true)));
The strtotime
function return an int
as shown here
Struggling with strtotime, getting expect parameter 2 to be long error
Read the documentation of strtotime()
: http://php.net/strtotime
It states that:
time [-> the first parameter]
A date/time string. Valid formats are explained in Date and Time Formats.
now [-> the second parameter]
The timestamp which is used as a base for the calculation of relative dates.
So, only the first parameter is a time expression in string form. The second parameter is the date you start from. (+ 1 year
from the unix timestamp strtotime($_POST['cdr_original_install_date'])
on)
So use:
strtotime('+ 1 year', strtotime($_POST['cdr_original_install_date']));
Related Topics
Pdoexception "Could Not Find Driver" in PHP
How Does PHP Compare Strings with Comparison Operators
File_Get_HTML Displays Fatal Error Call to Undefined Function
Undefined Index with PHP Sessions
Process Mathematical Equations in PHP
How to Select Default Value of a Field
What Does the MySQLi_Error() Expects Parameter 1 to Be MySQLi, Null Given Mean
Dynamic Shipping Fee Based on Custom Radio Buttons in Woocommerce
Send Email with Attachment Using PHP
How to Remove 'Index.Php' from Url in Codeigniter
Saving Images in Database MySQL
Enabling 'Strict_Types' Globally in PHP 7
Invoke External Shell Script from PHP and Get Its Process Id