Inserer la date et heure en php dans la base

Fermé
bfiguig - 7 août 2009 à 09:18
 bfiguig - 7 août 2009 à 15:23
Bonjour,
voila mon probleme, je voudrai inserer la date complet du jour (date et heure) dans une table oracle en PHP, mais je ne sais pas comment faire.
pour l'instant j'utilise cette formule : $date = date("d-m-Y");
mais moi je veux inserer la date et l'heure (par exemple sous cette forme : 30/06/2009 10h10)
merci de m'aider pour resoudre ce probleme
A voir également:

3 réponses

imw Messages postés 233 Date d'inscription vendredi 17 juillet 2009 Statut Membre Dernière intervention 8 septembre 2011 42
7 août 2009 à 09:22
$date = date("d/m/Y H:i:s");

RTFM : http://www.php.net/manual/fr/function.date.php
0
Re-bonjour,
j'ai fait ce que tu m'as dit, mais voila ça marche pas, j'ai ce message :

"ORA-01830: date format picture ends before converting entire input string "

et voila mon code :

$dates = date("d-m-Y H:i:s");
ensuite j'effectue l'insertion dans une table oracle

$stmt_insert_journal = OCIParse($conn, "INSERT INTO JOURNAL_PROJET (ID_EVENEMENT, DATE_EVENEMENT, ID_REDACTEUR, ID_CDP1, ID_CDP2, ID_DBA1, ID_DBA2, TEXTE_EVENEMENT, ID_PROJET) VALUES (:bind1, :bind2, :bind3, :bind4, :bind5, :bind6, :bind7, :bind8, :bind9)");

OCIBindByName($stmt_insert_journal, ":bind1", $RES_EVEN);
OCIBindByName($stmt_insert_journal, ":bind2", $dates);
OCIBindByName($stmt_insert_journal, ":bind3", $id_redacteur);
OCIBindByName($stmt_insert_journal, ":bind4", $id_cdp1);
OCIBindByName($stmt_insert_journal, ":bind5", $id_cdp2);
OCIBindByName($stmt_insert_journal, ":bind6", $id_dba1);
OCIBindByName($stmt_insert_journal, ":bind7", $id_dba2);
OCIBindByName($stmt_insert_journal, ":bind8", $texte_evenem);
OCIBindByName($stmt_insert_journal, ":bind9", $RES);

OCIExecute($stmt_insert_journal, OCI_COMMIT_ON_SUCCESS);

merci de votre aide
0
imw Messages postés 233 Date d'inscription vendredi 17 juillet 2009 Statut Membre Dernière intervention 8 septembre 2011 42
7 août 2009 à 11:30
j'y connais rien avec Oracle, mais à priori, le format date ne lui va pas bien ...

Regarde à quoi doit ressembler la date pour Oracle (type de colonne ...)
0
Re-bonjour,
en fait pour inserer une date complete dans une table oracle, il faut utiliser sysdate.
donc pour l'insertion ça marche, maintenant j'ai un autre probleme c'est l'affichage de la date :
le format de la date dans la table est : "07-août -2009 03:00:13 PM" mais je fais un select je n'ai plus le meme format j'ai ça : "07/08/09".
je ne comprend pas pourquoi ??

merci de votre aide
0