Jump to content
Sign in to follow this  
malainhocf

Data de hoje para inserir no mysql

Recommended Posts

malainhocf

Olá a todos, boa noite,

Como faço para gerar uma data com a data de hoje para ser inserida no mysql.

Isto é, tem que gerar por exemplo:  2011/01/2626

Obrigado


Cumprimentos

Cesar Oliveira

Desenvolvo websites e aplicações web

http://www.profissionalweb.net

Share this post


Link to post
Share on other sites
Mac135

certo

no php constróis uma querie sql do tipo

"INSERT INTO tablename (col_name, col_date) VALUE ('DATE: Auto CURDATE()', CURDATE() )";

depois é só enviares para a base de dados, desta maneira penso que resolves o problema

Share this post


Link to post
Share on other sites
Mac135

vamos lá ver se é desta que te consigo ajudar, já que só queres mesmo em php

tens este exemplo

<?php
// Assuming today is March 10th, 2001, 5:16:18 pm, and that we are in the
// Mountain Standard Time (MST) Time Zone

$today = date("F j, Y, g:i a");                 // March 10, 2001, 5:16 pm
$today = date("m.d.y");                         // 03.10.01
$today = date("j, n, Y");                       // 10, 3, 2001
$today = date("Ymd");                           // 20010310
$today = date('h-i-s, j-m-y, it is w Day');     // 05-16-18, 10-03-01, 1631 1618 6 Satpm01
$today = date('\i\t \i\s \t\h\e jS \d\a\y.');   // it is the 10th day.
$today = date("D M j G:i:s T Y");               // Sat Mar 10 17:16:18 MST 2001
$today = date('H:m:s \m \i\s\ \m\o\n\t\h');     // 17:03:18 m is month
$today = date("H:i:s");                         // 17:16:18
?>

podes ver mais em http://www.php.net/manual/en/function.date.php

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×
×
  • Create New...

Important Information

By using this site you accept our Terms of Use and Privacy Policy. We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.