...

View Full Version : date difference in php



heartlin
12-15-2008, 08:59 AM
hi,

I have one doubt regarding date.i have to insert the one date in my database.this field is used to the user is valid for that particular date.if that date exceeds,user shouldn't login his account.i don't know how that particular date exceeds?can anyone help me.thanks in advance..

Fumigator
12-15-2008, 09:43 AM
Why not just use MySQL's date functions? As long as your date is stored as a data type of "date" (it is, right?) then you can perform all kinds of functions on that date.

heartlin
12-15-2008, 10:22 AM
no i used the datatype varchar for date field.for example i gave 14.12.2008 in date field.if the user login today means,he will get the message 'you had crossed the valid date,contact admin'.

i don't know how this did in mysql.can u tell me how i do this in both php and mysql.

StupidRalph
12-15-2008, 10:42 AM
You really should store the date in an appropiate data type. From there you can just perform MySQL date functions that will handle most things for you. :thumbsup:

kokjj87
12-15-2008, 10:48 AM
For date i recommend mysql DATE format YYYY-DD-MM..

StupidRalph
12-15-2008, 11:31 AM
Also, just as a side note...you may want to backup your information before you attempt to convert it since simply changing your data type from varchar (in an inappropiate format) will truncate your current values and replace them with 0000-00-00 or something similar.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum