Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6
  1. #1
    New Coder
    Join Date
    Jan 2008
    Posts
    26
    Thanks
    0
    Thanked 0 Times in 0 Posts

    date difference in php

    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..

  • #2
    UE Antagonizer Fumigator's Avatar
    Join Date
    Dec 2005
    Location
    Utah, USA, Northwestern hemisphere, Earth, Solar System, Milky Way Galaxy, Alpha Quadrant
    Posts
    7,691
    Thanks
    42
    Thanked 637 Times in 625 Posts
    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.

  • #3
    New Coder
    Join Date
    Jan 2008
    Posts
    26
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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.

  • #4
    Senior Coder
    Join Date
    Mar 2003
    Location
    Atlanta
    Posts
    1,037
    Thanks
    14
    Thanked 30 Times in 28 Posts
    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.
    Most of my questions/posts are fairly straightforward and simple. I post long verbose messages in an attempt to be thorough.

  • #5
    Regular Coder kokjj87's Avatar
    Join Date
    Sep 2008
    Location
    Singapore
    Posts
    279
    Thanks
    1
    Thanked 55 Times in 54 Posts
    For date i recommend mysql DATE format YYYY-DD-MM..

  • #6
    Senior Coder
    Join Date
    Mar 2003
    Location
    Atlanta
    Posts
    1,037
    Thanks
    14
    Thanked 30 Times in 28 Posts
    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.
    Most of my questions/posts are fairly straightforward and simple. I post long verbose messages in an attempt to be thorough.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •