Forums
This topic is locked
makeDateTime function not working
10 Jun 2006 06:22:15 Matt Penn posted:
Dreamweaver kicks out this code to format a date coming from a mySQL database date field.<?php echo makeDateTime($row_news_detail['newsDate'], 'm/d/Y'); ?>
It is the same code that works on two of my other webhosting services. However, on my new webhost, I get the following error message:
Call to undefined function: makedatetime()...
My webhost says that this is not a built-in PHP function -- which appears to be true. So.... how has this worked for me in the past? Am I missing something? Thanks for any assistance!
Replies
Replied 13 Jun 2006 06:48:12
13 Jun 2006 06:48:12 ahmed zaheen replied:
please use this function in the header and try
function makeStamp($theString) {
if (ereg("([0-9]{4})-([0-9]{2})-([0-9]{2}) ([0-9]{2})<img src=../images/dmxzone/forum/icon_smile_sad.gif border=0 align=middle>[0-9]{2})<img src=../images/dmxzone/forum/icon_smile_sad.gif border=0 align=middle>[0-9]{2})", $theString, $strReg)) {
$theStamp = mktime($strReg[4],$strReg[5],$strReg[6],$strReg[2],$strReg[3],$strReg[1]);
} else if (ereg("([0-9]{4})-([0-9]{2})-([0-9]{2})", $theString, $strReg)) {
$theStamp = mktime(0,0,0,$strReg[2],$strReg[3],$strReg[1]);
} else if (ereg("([0-9]{2})<img src=../images/dmxzone/forum/icon_smile_sad.gif border=0 align=middle>[0-9]{2})<img src=../images/dmxzone/forum/icon_smile_sad.gif border=0 align=middle>[0-9]{2})", $theString, $strReg)) {
$theStamp = mktime($strReg[1],$strReg[2],$strReg[3],0,0,0);
}
return $theStamp;
}
function makeDateTime($theString, $theFormat) {
$theDate=date($theFormat, makeStamp($theString)); //the $theDate is your date field from record set,
return $theDate; // use format as you like, I used <?php echo makeDateTime($row_whatsdetails['theDate'], 'dS M, Y'); ?>
}
function makeStamp($theString) {
if (ereg("([0-9]{4})-([0-9]{2})-([0-9]{2}) ([0-9]{2})<img src=../images/dmxzone/forum/icon_smile_sad.gif border=0 align=middle>[0-9]{2})<img src=../images/dmxzone/forum/icon_smile_sad.gif border=0 align=middle>[0-9]{2})", $theString, $strReg)) {
$theStamp = mktime($strReg[4],$strReg[5],$strReg[6],$strReg[2],$strReg[3],$strReg[1]);
} else if (ereg("([0-9]{4})-([0-9]{2})-([0-9]{2})", $theString, $strReg)) {
$theStamp = mktime(0,0,0,$strReg[2],$strReg[3],$strReg[1]);
} else if (ereg("([0-9]{2})<img src=../images/dmxzone/forum/icon_smile_sad.gif border=0 align=middle>[0-9]{2})<img src=../images/dmxzone/forum/icon_smile_sad.gif border=0 align=middle>[0-9]{2})", $theString, $strReg)) {
$theStamp = mktime($strReg[1],$strReg[2],$strReg[3],0,0,0);
}
return $theStamp;
}
function makeDateTime($theString, $theFormat) {
$theDate=date($theFormat, makeStamp($theString)); //the $theDate is your date field from record set,
return $theDate; // use format as you like, I used <?php echo makeDateTime($row_whatsdetails['theDate'], 'dS M, Y'); ?>
}
Replied 13 Jun 2006 06:51:48
13 Jun 2006 06:51:48 ahmed zaheen replied:
Oh!!!! I found <img src=../images/dmxzone/forum/icon_smile_sad.gif border=0 align=middle> , -(, <img src=../images/dmxzone/forum/icon_smile_sad.gif border=0 align=middle>, as emoticons, please be careful about it, it's formatting and separators only
Replied 13 Jun 2006 10:39:43
13 Jun 2006 10:39:43 Roddy Dairion replied:
this is why you shud all use this button "#" and type all you code in between them.
Edited by - roders22 on 13 Jun 2006 13:20:39
Edited by - roders22 on 13 Jun 2006 13:20:39