Jump to content

Date Code not working


TeamTJ

Recommended Posts

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]

Link to comment
Share on other sites

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

 

 

Link to comment
Share on other sites

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>

Link to comment
Share on other sites

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 )
Link to comment
Share on other sites

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

Link to comment
Share on other sites

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

Link to comment
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.