TeamTJ Posted November 22, 2011 Share Posted November 22, 2011 I have a piece of .php that is supposed to create a type of calendar but it seems to be getting the date wrong and thinks that the date I've selected is 12/31/1969. Any ideas on how to get it to recognize the date I'm selecting in the form items? Thanks! Morgan [attachment deleted by admin] Quote Link to comment https://forums.phpfreaks.com/topic/251587-date-code-not-working/ Share on other sites More sharing options...
newb Posted November 22, 2011 Share Posted November 22, 2011 if you could post the snippets of code that you think are causing the problem then that would be nice. it would be much easier for me to view the code on a post than to download the file and open it in a program. Quote Link to comment https://forums.phpfreaks.com/topic/251587-date-code-not-working/#findComment-1290260 Share on other sites More sharing options...
teynon Posted November 22, 2011 Share Posted November 22, 2011 What is the value of $orderdate? Quote Link to comment https://forums.phpfreaks.com/topic/251587-date-code-not-working/#findComment-1290266 Share on other sites More sharing options...
TeamTJ Posted November 22, 2011 Author Share Posted November 22, 2011 What is the value of $orderdate? $orderdate is the value of whatever ie selected in the date fields of the form. It defaults to today, but when the line echo '<B>' . $year . '-' . $month . '-' . $day . '</B><hr>' . $orderdate . '<hr>'; is done, it shows 1969-Dec-31 instead of 2011-Nov-21 Quote Link to comment https://forums.phpfreaks.com/topic/251587-date-code-not-working/#findComment-1290271 Share on other sites More sharing options...
Pikachu2000 Posted November 22, 2011 Share Posted November 22, 2011 Post the code that generates that result. Quote Link to comment https://forums.phpfreaks.com/topic/251587-date-code-not-working/#findComment-1290276 Share on other sites More sharing options...
TeamTJ Posted November 22, 2011 Author Share Posted November 22, 2011 Post the code that generates that result. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <style type="text/css"> html,body { font-family:Arial, Helvetica, sans-serif; } .Day{ width: 3em; height: 3em; position: relative; float: left; font-size:11px; border: #000 1px solid; margin: 1px; text-align:center; } #Sat, #Sun{ background-color:#FF8080; } .Date{ font-size:1.2em; } .Year{ font-size:18px; font-weight:bold; text-align:center; } </style> <DIV CLASS="Year"></DIV><B>1969-Dec-31</B><hr><hr><DIV CLASS="Year">1969</DIV><hr><DIV CLASS="Day" ID="Wed"><SPAN CLASS="Month">Dec</SPAN><BR/><SPAN CLASS="Date">31</SPAN></DIV> Quote Link to comment https://forums.phpfreaks.com/topic/251587-date-code-not-working/#findComment-1290277 Share on other sites More sharing options...
Pikachu2000 Posted November 22, 2011 Share Posted November 22, 2011 I meant the PHP code. That's html. Quote Link to comment https://forums.phpfreaks.com/topic/251587-date-code-not-working/#findComment-1290278 Share on other sites More sharing options...
TeamTJ Posted November 22, 2011 Author Share Posted November 22, 2011 I meant the PHP code. That's html. Sorry, thought you meant the resulting code. php is attached to the initial post... Quote Link to comment https://forums.phpfreaks.com/topic/251587-date-code-not-working/#findComment-1290280 Share on other sites More sharing options...
teynon Posted November 22, 2011 Share Posted November 22, 2011 At the beginning of the page, put print_r($_POST); Then post the form and upload it. Looks like you are trying to use global variables though, which is a no-no. Quote Link to comment https://forums.phpfreaks.com/topic/251587-date-code-not-working/#findComment-1290282 Share on other sites More sharing options...
TeamTJ Posted November 22, 2011 Author Share Posted November 22, 2011 At the beginning of the page, put print_r($_POST); Then post the form and upload it. Looks like you are trying to use global variables though, which is a no-no. That give me Array ( [calTitle] => test [orderdate] => 21-NOV-2011 [submit] => Submit ) Quote Link to comment https://forums.phpfreaks.com/topic/251587-date-code-not-working/#findComment-1290287 Share on other sites More sharing options...
TeamTJ Posted November 22, 2011 Author Share Posted November 22, 2011 I just noticed that when I open the .php file, whether the first time or by hitting submit, the following gets created in the error_log file: [21-Nov-2011 22:42:04] PHP Warning: PHP Startup: Unable to load dynamic library '/usr/local/lib/php/extensions/no-debug-non-zts-20090626/memcache.so' - /usr/local/lib/php/extensions/no-debug-non-zts-20090626/memcache.so: cannot open shared object file: No such file or directory in Unknown on line 0 Quote Link to comment https://forums.phpfreaks.com/topic/251587-date-code-not-working/#findComment-1290290 Share on other sites More sharing options...
teynon Posted November 22, 2011 Share Posted November 22, 2011 Try calling $orderdate with $_POST['orderdate'] Quote Link to comment https://forums.phpfreaks.com/topic/251587-date-code-not-working/#findComment-1290296 Share on other sites More sharing options...
TeamTJ Posted November 22, 2011 Author Share Posted November 22, 2011 With all the pointers in this thread, I was able to fix it. I replaced //Print the title echo '<DIV CLASS="Year">' . $calTitle . '</DIV>'; //Convert the date to a usable format $explode = explode('-', $orderdate); $start = date( 'd-M-Y', strtotime($orderdate)); $explode = explode('-', $start); $day = $explode[0]; $month = $explode[1]; $year = $explode[2]; with //Print the title echo '<DIV CLASS="Year">' . $_POST['calTitle'] . '</DIV>'; //Convert the date to a usable format $explode = explode('-', $_POST['orderdate']); $start = date( 'd-M-Y', strtotime($_POST['orderdate'])); $explode = explode('-', $start); $day = $explode[0]; $month = $explode[1]; $year = $explode[2]; I'm guessing that I'm doing the variables the bad way and need to brush up on them Thanks for the help! Morgan Quote Link to comment https://forums.phpfreaks.com/topic/251587-date-code-not-working/#findComment-1290306 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.