dbTalk Databases Forums  

add date/time?

comp.databases.mysql comp.databases.mysql


Discuss add date/time? in the comp.databases.mysql forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Geoff Cox
 
Posts: n/a

Default add date/time? - 05-10-2008 , 01:21 AM






Hello,

I have pages using AJAX and php to add data to MySQL database.

What's the best way to add the date/time fror each addition of data?

Thanks

Geoff

Reply With Quote
  #2  
Old   
Luuk
 
Posts: n/a

Default Re: add date/time? - 05-10-2008 , 02:36 AM






Geoff Cox schreef:
Quote:
Hello,

I have pages using AJAX and php to add data to MySQL database.

What's the best way to add the date/time fror each addition of data?

Thanks

Geoff
use the date/time from your server, not from 'any' client posting.

--
Luuk


Reply With Quote
  #3  
Old   
Geoff Cox
 
Posts: n/a

Default Re: add date/time? - 05-10-2008 , 03:26 AM



On Sat, 10 May 2008 09:36:40 +0200, Luuk <Luuk (AT) invalid (DOT) lan> wrote:

Quote:
Geoff Cox schreef:
Hello,

I have pages using AJAX and php to add data to MySQL database.

What's the best way to add the date/time fror each addition of data?

Thanks

Geoff

use the date/time from your server, not from 'any' client posting.
Luuk,

Thanks for your reply.

I have just tried adding this to the php file and it seems to work OK.

1. in the php file

$dt1 = date("Y-m-d H:i:s");

2. to create in MySQL

dt1 datetime NOT NULL default '0000-00-00 00:00:00',

Is this not a good idea?

How would I get the server date/time into MySQL?

Cheers

Geoff


Reply With Quote
  #4  
Old   
Luuk
 
Posts: n/a

Default Re: add date/time? - 05-10-2008 , 05:37 AM



Geoff Cox schreef:
Quote:
On Sat, 10 May 2008 09:36:40 +0200, Luuk <Luuk (AT) invalid (DOT) lan> wrote:

Geoff Cox schreef:
Hello,

I have pages using AJAX and php to add data to MySQL database.

What's the best way to add the date/time fror each addition of data?

Thanks

Geoff
use the date/time from your server, not from 'any' client posting.

Luuk,

Thanks for your reply.

I have just tried adding this to the php file and it seems to work OK.

1. in the php file

$dt1 = date("Y-m-d H:i:s");

2. to create in MySQL

dt1 datetime NOT NULL default '0000-00-00 00:00:00',

Is this not a good idea?

How would I get the server date/time into MySQL?

Cheers

Geoff
http://dev.mysql.com/doc/refman/5.0/...functions.html

--
Luuk


Reply With Quote
  #5  
Old   
cvh@LE
 
Posts: n/a

Default Re: add date/time? - 05-12-2008 , 02:19 PM



On May 10, 12:37*pm, Luuk <L... (AT) invalid (DOT) lan> wrote:
Quote:
Geoff Cox schreef:



On Sat, 10 May 2008 09:36:40 +0200, Luuk <L... (AT) invalid (DOT) lan> wrote:

Geoff Cox schreef:
Hello,

I have pages using AJAX and php to add data to MySQL database.

What's the best way to add the date/time fror each addition of data?

Thanks

Geoff
use the date/time from your server, not from 'any' client posting.

Luuk,

Thanks for your reply.

I have just tried adding this to the php file and it seems to work OK.

1. in the php file

$dt1 = date("Y-m-d H:i:s");

2. to create in MySQL

dt1 datetime NOT NULL default '0000-00-00 00:00:00',

Is this not a good idea?

How would I get the server date/time into MySQL?

Cheers

Geoff

http://dev.mysql.com/doc/refman/5.0/...functions.html

--
Luuk
if you really only want to get the creation time why not use a
timestamp column that automatically saves the last update time?

saee: http://dev.mysql.com/doc/refman/5.0/en/timestamp.html
CVH


Reply With Quote
  #6  
Old   
Rik Wasmus
 
Posts: n/a

Default Re: add date/time? - 05-12-2008 , 02:37 PM



On Sat, 10 May 2008 10:26:50 +0200, Geoff Cox <gcox (AT) freeuk (DOT) notcom> wrote:

Quote:
On Sat, 10 May 2008 09:36:40 +0200, Luuk <Luuk (AT) invalid (DOT) lan> wrote:

Geoff Cox schreef:
Hello,

I have pages using AJAX and php to add data to MySQL database.

What's the best way to add the date/time fror each addition of data?

Thanks

Geoff

use the date/time from your server, not from 'any' client posting.

Luuk,

Thanks for your reply.

I have just tried adding this to the php file and it seems to work OK.

1. in the php file

$dt1 = date("Y-m-d H:i:s");

2. to create in MySQL

dt1 datetime NOT NULL default '0000-00-00 00:00:00',

I usually rather have NULLs for no data, then an invalid one (there is no
year 0).

Quote:
Is this not a good idea?
How would I get the server date/time into MySQL?
NOW()
--
Rik Wasmus
[SPAM] Now temporarily looking for some smaller PHP/MySQL projects/work to
fund a self developed bigger project, mail me at rik at rwasmus.nl. [/SPAM]


Reply With Quote
  #7  
Old   
Michael Austin
 
Posts: n/a

Default Re: add date/time? - 05-12-2008 , 05:51 PM



Rik Wasmus wrote:
Quote:
On Sat, 10 May 2008 10:26:50 +0200, Geoff Cox <gcox (AT) freeuk (DOT) notcom> wrote:

On Sat, 10 May 2008 09:36:40 +0200, Luuk <Luuk (AT) invalid (DOT) lan> wrote:

Geoff Cox schreef:
Hello,

I have pages using AJAX and php to add data to MySQL database.

What's the best way to add the date/time fror each addition of data?

Thanks

Geoff

use the date/time from your server, not from 'any' client posting.

Luuk,

Thanks for your reply.

I have just tried adding this to the php file and it seems to work OK.

1. in the php file

$dt1 = date("Y-m-d H:i:s");

2. to create in MySQL

dt1 datetime NOT NULL default '0000-00-00 00:00:00',


I usually rather have NULLs for no data, then an invalid one (there is
no year 0).

Is this not a good idea?
How would I get the server date/time into MySQL?

NOW()

and if you don't want to make "code" changes - add a timestamp column to
your table and add a trigger to automatically update it.

See the docs for BEFORE INSERT,UPDATE triggers.


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.