Jump to content

Recommended Posts

Warning: mktime() expects parameter 1 to be long, string given

 

any help would be appreciated ???

 

Code:

 

<?php
function formatDate($val)
  {
      list($date, $time) = explode(" ", $val);
      list($year, $month, $day) = explode("-", $date);
      list($hour, $minute, $second) = explode (":", $time);
      return date("l, m.j.y @ H:ia", mktime($hour, $minute, $second, $month, $day, $year));//error line
  }

?>

 

 

Link to comment
https://forums.phpfreaks.com/topic/141168-time-question/
Share on other sites

this is pushing a datatype related error, php handles datatype conversions as you attempt to convert them..

 

you could fix this by converting them into themselves but their numeric equivelent to the string versions

 

      return date("l, m.j.y @ H:ia", mktime(($hour * 1), ($minute * 1), ($second * 1), ($month * 1), ($day * 1), ($year * 1)));//error line

Link to comment
https://forums.phpfreaks.com/topic/141168-time-question/#findComment-738889
Share on other sites

I just re-read your post, however, my script SHOULD work; you could just use strtotime() on your currently formatted date string, and that wioll return a unix timestamp for which you can use date() with in order to [re-]format your date

Link to comment
https://forums.phpfreaks.com/topic/141168-time-question/#findComment-738898
Share on other sites

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.