Jump to content

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

I mispelled it, but yeah I "copypasta'd" it

 

thanks for spotting that

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

Link to comment
https://forums.phpfreaks.com/topic/125019-mktime-error/#findComment-646114
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.