Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

The Database Forum


You are currently viewing our The Database Forum as a guest. Please register to participate.
Login



Reply
Adding the date and time
Old 09-01-2006, 11:59 PM Adding the date and time
jason_bristol's Avatar
Ultra Talker

Latest Blog Post:
New site - ConnectFrench.com
Posts: 310
Name: Jason Eyermann
Location: england bristol
Trades: 0
I use phpMyAdmin with a Remote server using mySQL.
I tried using the date option as one of the fields for the first time. I read a little into it first. I used datetime and for the default it added 0000-00-00 00:00:00.
I set it up on my site but a time or date did not appear in the table when data was inserted in the form.
How do I get the date to appear. All that appeared was my name - jason and under date - 0000-00-00 00:00:00 appeared.

Who's time would it be anyway. Would it be the time and date of the server or the browser?

thanks

jason
__________________

Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE
jason_bristol is offline
Reply With Quote
View Public Profile Visit jason_bristol's homepage!
 
 
Register now for full access!
Old 09-02-2006, 12:37 AM Re: Adding the date and time
mgraphic's Avatar
Truth Seeker

Latest Blog Post:
JAMISONTUNES
Posts: 2,898
Name: Keith Marshall
Location: Connecticut
Trades: 0
You can have mysql auto insert the current timestamp if you set the default to CURRENT_TIMESTAMP or when you do an insert or update, you can call NOW() which is a mysql function for inserting the current timestamp. These methods will automatically be formatted by what the field needs.

The timestamp returns the Unix timestamp GMT which is Unix Epoch (January 1st, 1970) so it will need to be adjusted for the timezone offset for your target time if your want to display it to your users.
__________________

<mgraphic /> - I don't have a solution but I admire the problem.
mgraphic is offline
Reply With Quote
View Public Profile
 
Old 09-06-2006, 09:00 PM Re: Adding the date and time
jason_bristol's Avatar
Ultra Talker

Latest Blog Post:
New site - ConnectFrench.com
Posts: 310
Name: Jason Eyermann
Location: england bristol
Trades: 0
Issue solved. I first changed one of the settings to current_timestamp but it still did not work thenI was just playing around with it. I tried changing not null to null and now it works. way hay! (thanks for the help mgraphic)

The one last problem is the date come out as '2006-09-06 16:54:21' is there any way to swop the day month and year around?
__________________

Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE

Last edited by jason_bristol; 09-06-2006 at 09:37 PM..
jason_bristol is offline
Reply With Quote
View Public Profile Visit jason_bristol's homepage!
 
Old 09-07-2006, 01:34 AM Re: Adding the date and time
mgraphic's Avatar
Truth Seeker

Latest Blog Post:
JAMISONTUNES
Posts: 2,898
Name: Keith Marshall
Location: Connecticut
Trades: 0
This is the perferred format for sql to store the datetime stamp, because it will always sort in correct order. You can certainly reformat it once you pull it from the db, or store it as a varchar field, but you would lose all benifits of the sql datetime functions cause it would not see it as datetime.
__________________

<mgraphic /> - I don't have a solution but I admire the problem.
mgraphic is offline
Reply With Quote
View Public Profile
 
Old 09-07-2006, 11:04 AM Re: Adding the date and time
jason_bristol's Avatar
Ultra Talker

Latest Blog Post:
New site - ConnectFrench.com
Posts: 310
Name: Jason Eyermann
Location: england bristol
Trades: 0
sorry. one last problem.

The time and date given is incorrect by a number of hours. My guess is that the time is taken from the remote server which is in California and i'm in England. Is there anyway of adding the browswer time?

Details i've added in phpmyadmin -

Field | type |Lenght/Values| Attributes | Null | Default
---------------------------------------------------------------------------------------------------
Time | timestamp | |on update current_timestamp| null |(I ticked
Current_timestamp)
__________________

Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE
jason_bristol is offline
Reply With Quote
View Public Profile Visit jason_bristol's homepage!
 
Reply     « Reply to Adding the date and time
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.19072 seconds with 12 queries