Page 1 of 1

date format

Posted: Wed May 20, 2009 2:20 am
by santille
date format

Hello,

Code: Select all

for($m = 0;$m <= 0; $m++)
{
$now = date ("Y-m-d", mktime (0,0,0,date("m"),date("d")+$m,date("Y")));
echo "<input type=\"hidden\" name=\"open_date\" value=\"" . $now . "\">";
}
With this piece of code I want to get the following format with the hour and the minutes :
20-05-2009 10:00

Do you know how to modify?

Thanks,

seb

Re: date format

Posted: Wed May 20, 2009 2:54 am
by jaoudestudios
$now = date ("Y-m-d", mktime (0,0,0,date("m"),date("d")+$m,date("Y")));
To...

Code: Select all

$now = date ("d-m-Y h:i", mktime (0,0,0,date("m"),date("d")+$m,date("Y")));

Re: date format

Posted: Wed May 20, 2009 3:15 am
by santille
I've tried but unsuccessfull!
The result with your code is : 0000-00-00
Another idea?

Thanks

Re: date format

Posted: Wed May 20, 2009 3:33 am
by onion2k
If you used jaoudestudios you can't have 0000-00-00. You did something wrong.

Re: date format

Posted: Wed May 20, 2009 3:36 am
by jaoudestudios
for($m = 0;$m <= 0; $m++)
That is wrong! It wont run. Because $m will always be greater than 0.

Re: date format

Posted: Wed May 20, 2009 3:47 am
by santille
I've taken off this for loop but without success : always 0000-00-00 as the result..

Any idea?

Thanks,

seb

Re: date format

Posted: Wed May 20, 2009 3:51 am
by jaoudestudios
Repost your current code

Re: date format

Posted: Wed May 20, 2009 3:55 am
by santille

Code: Select all

$now = date ("d-m-Y h:i", mktime (0,0,0,date("m"),date("d")+$m,date("Y")));
echo "<input type=\"hidden\" name=\"open_date\" value=\"" . $now . "\">";

Re: date format

Posted: Wed May 20, 2009 4:16 am
by jaoudestudios
I ran...

Code: Select all

$now = date ("d-m-Y h:i", mktime (0,0,0,date("m"),date("d")+$m,date("Y")));
and get this...

Code: Select all

20-05-2009 12:00
NB: $m is undefined

Re: date format

Posted: Wed May 20, 2009 4:42 am
by santille
Here is the complete code of the page :

Code: Select all

 
<?
include 'header.php';
include 'format.css';
$queryu = "SELECT * FROM $userstable WHERE (userlevel = '2' OR userlevel = '3' OR userlevel = 'A') AND username = '$tmpname'";
$resultu = mysql_query($queryu); 
$rowu= mysql_fetch_array($resultu);
$userlevel = $rowu['userlevel'];
 
if($userlevel == '2'){
// DO NOTHING
echo "<table bgcolor=\"#ECECEC\" cellpadding=\"3\" cellspacing=\"0\" align=\"center\" class=\"black\" border=\"0\">";
echo "<tr>";
echo "<td>You must have manager access to enter this area.</td>";
echo "</tr><table>";
}else{
//ELSE, SHOW FORM BELOW - Begin manager form
include 'includes/inputcheck.php';
echo "<td>";
 
echo "<table bgcolor=\"#ECECEC\" cellpadding=\"3\" cellspacing=\"0\" align=\"center\" class=\"black\" border=\"0\">";
echo "<tr><td bgcolor=\"#ECECEC\" align=\"center\"><b>Task Creation</b></td><td bgcolor=\"#F2F2F2\" align=\"center\"><b>Customer Maintenance</b></td></tr>";
echo "<tr><td>";
 
echo "<table bgcolor=\"#ECECEC\" cellpadding=\"3\" cellspacing=\"0\" align=\"center\" class=\"black\">";
echo "<tr><form name=\"form1\" method=\"post\" onSubmit=\"return (formCheck(this))\" action=\"complete.php?getid=1\">";
echo "<td align=\"right\"><b>Customer:</b></td> ";
echo "<td><select name=\"catname\">";
echo "<option value=\"\"></option>";
include 'includes/catecon.php';
echo "</select></td></tr>";
/*for($m = 0;$m <= 0; $m++){
    $now = date("Y-m-d h:i", strtotime("now + $m day"));
    echo "<input type='hidden' name='open_date' value='$now' />\n";
}*/
for($m = 0;$m <= 0; $m++)
{
$now = date ("Y-m-d", mktime (0,0,0,date("m"),date("d")+$m,date("Y")));
echo "<input type=\"hidden\" name=\"open_date\" value=\"" . $now . "\">";
}
/*echo "<tr><td align=\"right\"><b>Priority:</b></td><td><select name=\"priority\">";
echo "<option value=\"\"></option>";
include 'includes/priorcon.php';
echo "</select> <font size=\"1\">Lower numbers are higher priority</font></td></tr>";*/
echo "<tr><td align=\"right\"><b>Customer Site:</b><td><input type=\"text\" name=\"site\" value=\"\" size=\"25\"><br></td></tr>";
echo "<tr><td align=\"right\"><b>Modem #:</b><td><input type=\"text\" name=\"modem\" value=\"\" size=\"25\"><br></td></tr>";
echo "<tr><td align=\"right\"><b>Task Name:</b><td><input type=\"text\" name=\"title\" value=\"\" size=\"25\"><br></td></tr>";
echo "<tr><td align=\"right\"><b>Description:</b><td><textarea name=\"description\" cols=\"25\" rows=\"5\"></textarea><br></td></tr>";
echo "<tr><td align=\"right\"><b>Assignee:</b></td><td><select name=\"personnel\">";
echo "<option value=\"\"></option>";
include 'includes/personnel.php';
echo "</select></td></tr>";
echo "<tr><td align=\"right\"><b>Caller's Name:</b><td><input type=\"text\" name=\"caller\" value=\"\" size=\"25\"><br></td></tr>";
echo "<tr><td align=\"right\"><input type=\"submit\" value=\"Submit Task\"></td></tr>";
echo "<tr><td align=\"center\" colspan=\"2\">";
echo "</form></td></tr></table>";
echo "</td>";
 
echo "<td bgcolor=\"#F2F2F2\" valign=\"top\"><br>";
echo "<table width=\"70%\" cellpadding=\"3\" cellspacing=\"0\" align=\"center\" class=\"black\" border=\"0\">";
$sql = "SELECT * FROM $taskstable WHERE taskid = '$taskid' GROUP BY open_date";
$result = mysql_query($sql);
$row = mysql_fetch_array($result);
echo "<form name=\"form2\" method=\"post\" onSubmit=\"return (formCheck(this))\" action=\"complete.php?getid=112\">";
echo "<tr><td align=\"right\" colspan=\"2\"><b>Add:</b> <input type=\"text\" name=\"catname\" value=\"\" size=\"20\"> <input type=\"submit\" value=\"Add Customer\"></td></tr></form>";
 
echo "<form name=\"form2\" method=\"post\" action=\"complete.php?getid=56\"><tr><td align=\"right\" colspan=\"2\"><br> <b>Delete:</b> 
<select name=\"catnamedel\"><option value=\"\"></option>";
include 'includes/catecon.php';
echo "</select> <input type=\"submit\" value=\"Delete Customer\"></td>";
echo "</tr></form>";
echo "</table>";
 
echo "</td>";
echo "</tr><table>";
 
echo "<br><br></td>";
echo "</tr>";
echo "</table>";
}
/*include 'footer.php';*/
 
?>
 

Re: date format

Posted: Thu May 21, 2009 8:55 am
by rugbyfreak

Code: Select all

date_default_timezone_set('Europe/Brussels');
$date=date(" d - m - y  g:m:s");
echo $date;
$sql="INSERT INTO commentaire (commentaire, datetime) 
VALUES
('$_POST[commentaire]','$_POST[date]')";
 
1) the 'commentaire' is always posted but not the date.
2) do i have to echo the date to post it?

Re: date format

Posted: Thu May 21, 2009 9:01 am
by Benjamin
rugbyfreak - use

Code: Select all

when posting code.

Re: date format

Posted: Thu May 21, 2009 9:08 am
by jaoudestudios
rugbyfreak wrote:2) do i have to echo the date to post it?
No, remove the quotes!