943,747 Members | Top Members by Rank

Ad:
  • PHP Discussion Thread
  • Marked Solved
  • Views: 1742
  • PHP RSS
You are currently viewing page 1 of this multi-page discussion thread
Mar 12th, 2009
0

storing date mysql

Expand Post »
hi all,
Donn't know much php...........
i want that when user register,his registration date store in db.i want to use server date not his system date in db.

thankx in adva...
Similar Threads
Reputation Points: 15
Solved Threads: 5
Junior Poster
rohitrohitrohit is offline Offline
120 posts
since Oct 2007
Mar 12th, 2009
0

Re: storing date mysql

php already uses the server's date.
Sponsor
Featured Poster
Reputation Points: 550
Solved Threads: 728
Bite my shiny metal ass!
pritaeas is offline Offline
4,166 posts
since Jul 2006
Mar 12th, 2009
0

Re: storing date mysql

Quote ...
i want that when user register,his registration date store in db.i want to use server date not his system date in db.
Php uses the server date, unlike other languages it is not reliant on the users system date and time.
Do you need help coding this or was it just a question?
Reputation Points: 12
Solved Threads: 16
Posting Whiz
Designer_101 is offline Offline
314 posts
since Jul 2007
Mar 12th, 2009
0

Re: storing date mysql

actually i have a table user_register_mobile in mysql. [Email,MobileNumber,Registratinon_date... are some filed there.] in this table i have a field registration_date.i want to keep date so that i know when user register to our site.

i read about timestamp,some date,time functon of php,but didn't get it. but if u want explain it i am ready to learn
Reputation Points: 15
Solved Threads: 5
Junior Poster
rohitrohitrohit is offline Offline
120 posts
since Oct 2007
Mar 12th, 2009
0

Re: storing date mysql

In your mysql table you should set the type to 'timestamp' and then set the default to 'CURRENT TIMESTAMP'.

It doesnt really need to be explained. All that is doing is getting the date and time from the server and sticking it in a field. Just remember not to update it when you update the table, that way it will stay the day the user registrated.
Hope this helps, if you need anything else or i've miss understood dont hesitate to ask.

Also, if you need more info on timestamp and storing the date, i suggest you consult the manual. It contains some really usefull stuff.
Reputation Points: 12
Solved Threads: 16
Posting Whiz
Designer_101 is offline Offline
314 posts
since Jul 2007
Mar 12th, 2009
0

Re: storing date mysql

Store a UNIX Timestamp in that mysql column.

php Syntax (Toggle Plain Text)
  1. <?php
  2. $iCurrentTime = time();

$iCurrentTime would result in an integer like: 1236884436
Which is the number of seconds since the Unix Epoch.

You can pass that integer into the php date() function and format it any way you want, and you can also calculate against it simply using basic math.

The only drawback is that it can not store dates after 01/2038 because it will exceed the size of a 32bit integer or Before 01/1970. By 2038 I imagine 64bit hardware or greater will pretty much be the norm.
Sponsor
Reputation Points: 265
Solved Threads: 126
Practically a Master Poster
mschroeder is offline Offline
624 posts
since Jul 2008
Mar 12th, 2009
0

Re: storing date mysql

likewise sql now()
is equivalent to php time()
Reputation Points: 562
Solved Threads: 368
Posting Maven
almostbob is offline Offline
2,970 posts
since Jan 2009
Mar 12th, 2009
0

Re: storing date mysql

or UNIX_TIMESTAMP()
Sponsor
Reputation Points: 265
Solved Threads: 126
Practically a Master Poster
mschroeder is offline Offline
624 posts
since Jul 2008
Mar 13th, 2009
0

Re: storing date mysql

i did as u told me in last thred,i insert a recode but when i see column Registration_date it shows 0000-00-00 00:00:00?
Reputation Points: 15
Solved Threads: 5
Junior Poster
rohitrohitrohit is offline Offline
120 posts
since Oct 2007
Mar 13th, 2009
0

Re: storing date mysql

That is because your column type is set to datetime or timestamp not certain which one actually produces that as I don't use the mysql datetime or timestamp data type.

To store a unix timestamp you just need an INT(10)
Sponsor
Reputation Points: 265
Solved Threads: 126
Practically a Master Poster
mschroeder is offline Offline
624 posts
since Jul 2008

This thread is solved

Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in PHP Forum Timeline: Mysql result in columns
Next Thread in PHP Forum Timeline: PHP unlink ERROR !!!





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC