Web Analytics Made Easy -
StatCounter php date help - CodingForum

Announcement

Collapse
No announcement yet.

php date help

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • php date help

    Hi,

    I need to store a download date in a MySQL Database when a user makes an order, and check to see if that download date has expired when the user logs in in the future. What would be the best way to do this? timestamp?

    Is there a PHP function that can anaylze the timestamp (or some sort of date string) and check to see how much time is left?

    Example: User orders download access for 24 hours - Comes back 5 hours, 20 minutes later - It should tell him that he has 18 hours fourty minutes left.

    I just need help on the timestamp/php date/math function... I've got the database queries down.

    Thanks!

  • #2
    If you store the value in a field that is data type "timestamp" or "datetime" then you can take advantage of MySQL's datetime functions. For example if you stored the timestamp someone's download time begins:
    Code:
    SELECT (date_add(begin_timestamp, interval 24 hours) - now()) as time_left

    Comment

    Working...
    X