PHP Classes

Correction for current date

Recommend this page to a friend!

      Date_picker  >  All threads  >  Correction for current date  >  (Un) Subscribe thread alerts  
Subject:Correction for current date
Summary:Bug fix for PHP5 current date
Messages:4
Author:Stephen Putman
Date:2008-07-14 18:40:11
Update:2008-07-17 03:05:30
 

  1. Correction for current date   Reply   Report abuse  
Picture of Stephen Putman Stephen Putman - 2008-07-14 18:40:11
The "default to current date" functionality (getdate()) does not work properly for PHP5. The getdate() function returns an associative array with date information in it, whereas this class expects to read dates in MySQL standard format - which is why I'm using this class. To fix this, change each reference to "getdate()" to "date("y-m-d")". This will yield the system date in MySQL format, and will enable the "default to current date" functionality to work properly.

Thanks for an otherwise killer class!

- Steve Putman
Lemon Curry Solutions Ltd
http://www.random-curry.com

  2. Re: Correction for current date   Reply   Report abuse  
Picture of Sandon Jurowski Sandon Jurowski - 2008-07-14 19:11:31 - In reply to message 1 from Stephen Putman
Thanks Steve! I'll take a look and try to get the changes made to the online class files soon.

-Sandon

  3. Re: Correction for current date   Reply   Report abuse  
Picture of Stephen Putman Stephen Putman - 2008-07-14 20:32:23 - In reply to message 2 from Sandon Jurowski
No problem, Sandon.

Quick question - how would I use this in an input form? It doesn't seem to send anything to _GET or _POST...hopefully, I'm just having a brain cramp...

Thanks, Steve

  4. Re: Correction for current date   Reply   Report abuse  
Picture of Sandon Jurowski Sandon Jurowski - 2008-07-17 03:05:30 - In reply to message 3 from Stephen Putman
Give the following code a shot. For a limited time you can see it in action here: http://safekids2.pediatrics.wisc.edu/date_test/test.php

<?php
include "class.Date_picker.php";
$my_form = new Date_picker;
$follow_up_date = $_REQUEST['follow_up_date_year']."-".$_REQUEST['follow_up_date_month']."-".$_REQUEST['follow_up_date_day'];
echo $follow_up_date;
echo " <form name=main_form>";
$today = getdate();
$default_year = $today[year];
#$this->my_form->print_date_pulldown("follow_up_date", $row_followup['follow_up_date'], 1, 0, 2004, $default_year);
$my_form->print_date_pulldown("follow_up_date", "2004-1-4", 1, 0, 2004, $default_year);
#print_date_pulldown("follow_up_date", "2004-1-4", 1, 0, 2004, $default_year);

echo '
<input type="submit" name="click_record" value="Update">
</form>
';
?>