Jump to content

Mktime Error


TheUnknown

Recommended Posts

Yo F1

Heres all the code

 

function mysql_timestamp($dt, $blank="") {
/* returns formatted MySQL timestamp, or $blank if it's blank */

if (empty($dt)) return $blank;

$yr = strval(substr($dt,0,4));
$mo = strval(substr($dt,4,2));
$da = strval(substr($dt,6,2));
$hr = strval(substr($dt,8,2));
$mi = strval(substr($dt,10,2));

return date("m/d/Y", strtotime($hr,$mi,0,$mo,$da,$yr));
}

Link to comment
https://forums.phpfreaks.com/topic/125019-mktime-error/#findComment-646039
Share on other sites

OK, perfect. Just use that last example I listed and make your function look like this:

 

<?php
function mysql_timestamp($dt, $blank="") {
/* returns formatted MySQL timestamp, or $blank if it's blank */
if (empty($dt)) return $blank;
return date("m/d/Y", strtotime($dt));
}
?>

Link to comment
https://forums.phpfreaks.com/topic/125019-mktime-error/#findComment-646045
Share on other sites

instead of strval......use intval

$yr = strval(substr($dt,0,4));

$mo = strval(substr($dt,4,2));

$da = strval(substr($dt,6,2));

$hr = strval(substr($dt,8,2));

$mi = strval(substr($dt,10,2));

that's too much work.

 

try this script instead

$yr = date("Y", strtotme($dt));
$mo = date("m", strtotme($dt));
$da = date("d", strtotme($dt));
$hr = date("G", strtotme($dt));
$mi = date("i", strtotme($dt));

Link to comment
https://forums.phpfreaks.com/topic/125019-mktime-error/#findComment-646106
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.