How to add the time and date into MySql?
Moderator: General Moderators
How to add the time and date into MySql?
I add some informations in the MySql with a form (Like: Name, Last Name, Age etc...), and I want to add the Current Time&Date into database, so I don't want to write the current time&date by myself.
Re: How to add the time and date into MySql?
use php function date('Y-m-j H:i:s')
Re: How to add the time and date into MySql?
Can you tell me an example? Where I have to write it? In the form or where?
-
jcrensha627
- Forum Newbie
- Posts: 15
- Joined: Fri Feb 27, 2009 11:34 pm
Re: How to add the time and date into MySql?
micro, im pretty new myself but i believe you do it from the backend. are u using phpmyadmin?? if so create another column named time and change the type to datetime or whatever other option want. if your not using myadmin im not to sure. hope this helped 
Re: How to add the time and date into MySql?
Use MySQL function NOW()
There are 10 types of people in this world, those who understand binary and those who don't
Re: How to add the time and date into MySql?
I'm to confuse, here is my code where to put or what to do, yes I'm using phpmyadmin:
p.s. If you don't understand anything just ask, cause some variables etc... are in Albanian.
Code: Select all
<html>
<body>
<?php
include ("menu/menu.php");
if (empty($_POST['dergo']))
{
?>
<TABLE class="col_top" width="800" align="left" cellspacing="0" cellpadding="0" border="0">
<TR>
<TD valign="left">
</br>
<strong><center><form action="<?=$_SERVER['PHP_SELF']?>" method="post">
Emri: <input type="text" name="emri" /></br>
Lajmi: <textarea name="lajmi" rows="5" cols="26"></textarea></br>
Data: <input type="data" name="data" /></br>
<input type="submit" name="dergo" value="Dërgo" />
</form></center></strong>
<?php
}
if (isset($_POST['dergo'])) {
include ('konfig.php');
$con = mysql_connect("$serveri","$username","$fjalekalimi");
if (!$con)
{
die('Nuk Mund Të Konektohet: ' . mysql_error());
}
mysql_select_db("$databaza", $con);
$sql="INSERT INTO lajmet (emri, lajmi, data)
VALUES ('$_POST[emri]','$_POST[lajmi]','$_POST[data]')";
if (!mysql_query($sql,$con))
{
die('Error: ' . mysql_error());
}
echo "</br><center><strong>Lajmi U Shtua Me Sukses Nga: $_POST[emri] <strong></br></center>";
echo '<center><a href="http://localhost/elektro/shto.php">Kthehu</a> Prapa Për Të Shtuar Lajm Të Ri</center>';
mysql_close($con);
}
?>
<?php
include ('posht.php');
?>
</TR>
</TABLE>
</body>
</html>
Re: How to add the time and date into MySql?
There are 10 types of people in this world, those who understand binary and those who don't
Re: How to add the time and date into MySql?
Everything is fine now with it, I'm using as a variable $time= date("l d F Y, H:i:s"); But now I would like the days and months to be in my language, Is any way to change the name of the days and months like, Monday, Tuesday, January etc...