Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/dangon27/decolore.maslindo.com/forum/includes/bbcode.php on line 483

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/dangon27/decolore.maslindo.com/forum/includes/bbcode.php on line 483

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/dangon27/decolore.maslindo.com/forum/includes/bbcode.php on line 483

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/dangon27/decolore.maslindo.com/forum/includes/bbcode.php on line 483

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/dangon27/decolore.maslindo.com/forum/includes/bbcode.php on line 483

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/dangon27/decolore.maslindo.com/forum/includes/bbcode.php on line 483

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/dangon27/decolore.maslindo.com/forum/includes/bbcode.php on line 483

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/dangon27/decolore.maslindo.com/forum/includes/bbcode.php on line 483

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/dangon27/decolore.maslindo.com/forum/includes/bbcode.php on line 483

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/dangon27/decolore.maslindo.com/forum/includes/bbcode.php on line 483

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/dangon27/decolore.maslindo.com/forum/includes/bbcode.php on line 483

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/dangon27/decolore.maslindo.com/forum/includes/bbcode.php on line 483

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/dangon27/decolore.maslindo.com/forum/includes/bbcode.php on line 483

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/dangon27/decolore.maslindo.com/forum/includes/bbcode.php on line 483

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/dangon27/decolore.maslindo.com/forum/includes/bbcode.php on line 483

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/dangon27/decolore.maslindo.com/forum/includes/bbcode.php on line 483

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/dangon27/decolore.maslindo.com/forum/includes/bbcode.php on line 483

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/dangon27/decolore.maslindo.com/forum/includes/bbcode.php on line 483

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/dangon27/decolore.maslindo.com/forum/includes/bbcode.php on line 483

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/dangon27/decolore.maslindo.com/forum/includes/bbcode.php on line 483

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/dangon27/decolore.maslindo.com/forum/includes/bbcode.php on line 483

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/dangon27/decolore.maslindo.com/forum/includes/bbcode.php on line 483

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/dangon27/decolore.maslindo.com/forum/includes/bbcode.php on line 483

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/dangon27/decolore.maslindo.com/forum/includes/bbcode.php on line 483

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/dangon27/decolore.maslindo.com/forum/includes/bbcode.php on line 483

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/dangon27/decolore.maslindo.com/forum/includes/bbcode.php on line 483

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/dangon27/decolore.maslindo.com/forum/includes/bbcode.php on line 112
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 3824: Cannot modify header information - headers already sent by (output started at /includes/bbcode.php:483)
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 3826: Cannot modify header information - headers already sent by (output started at /includes/bbcode.php:483)
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 3827: Cannot modify header information - headers already sent by (output started at /includes/bbcode.php:483)
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 3828: Cannot modify header information - headers already sent by (output started at /includes/bbcode.php:483)
decolore.maslindo.com • Afficher le sujet - php - saisie d'une date dans un formulaire

Welcome Guest ( Connexion | M’enregistrer )



Heures au format UTC + 1 heure



Poster un nouveau sujet Répondre au sujet  [ 1 message ] 
Auteur Message
 Sujet du message: php - saisie d'une date dans un formulaire
MessagePosté: Mar 2 Nov 2010 11:37 
Administrateur du site

Inscription: Lun 9 Nov 2009 17:10
Messages: 75

Hors ligne
Voici un code en php pour écrire dans un champ la date en bon format, avec validation.

On autorise à écrire le champ date soit avec un slash : /
Ex : 02/11/2010
Soit avec un tirait : -
Ex : 02-11-2010

Code:
if(preg_match("#^([0-9]{2}/){2}[0-9]{4}$#", $_POST['date'])) {
$date = explode('/', $_POST['date']);
if(checkdate($date[1], $date[0], $date[2]))
echo 'date correcte';
else echo 'date incorrecte';
}
elseif(preg_match("#^([0-9]{2}-){2}[0-9]{4}$#", $_POST['date'])) {
$date = explode('-', $_POST['date']);
if(checkdate($date[1], $date[0], $date[2]))
echo 'date correcte';
else echo 'date incorrecte';
}
else{
echo 'date incorrecte';
}


 Profil Envoyer un e-mail  
 
Afficher les messages postés depuis:  Trier par  
Poster un nouveau sujet Répondre au sujet  [ 1 message ] 

Heures au format UTC + 1 heure


Qui est en ligne

Utilisateurs parcourant ce forum: Aucun utilisateur enregistré et 1 invité


Vous ne pouvez pas poster de nouveaux sujets
Vous ne pouvez pas répondre aux sujets
Vous ne pouvez pas éditer vos messages
Vous ne pouvez pas supprimer vos messages
Vous ne pouvez pas joindre des fichiers

Rechercher:
Aller à:  
cron