how to make time counter in php

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
dharprog
Forum Contributor
Posts: 126
Joined: Fri Oct 27, 2006 12:20 am

how to make time counter in php

Post by dharprog »

Hi,

How to make time counter.

Suppose i purchased one item online, After that instance time starts decreasing cos he has given the time bound (like after purchase time item available only for 48 hours like that) So how it sets and how it decreases?

Setting the time i know by using time() function but how to make it timer?

Can anybody help me from this?

Thank YOu
User avatar
andym01480
Forum Contributor
Posts: 390
Joined: Wed Apr 19, 2006 5:01 pm

Post by andym01480 »

Use a database table - with columns for customer/purchase_id and a timestamp of purchase. Or put the data in a writeable file.

Then when they log in or whatever grab the time stamp for their customer/purchase_id and check <48hrs has passed
User avatar
dharprog
Forum Contributor
Posts: 126
Joined: Fri Oct 27, 2006 12:20 am

thank you

Post by dharprog »

HI

Thank YOu ... but again a small doubt how can i set that as <48 hours?

cos see this is the time stamp like time(). I'm using this fucntion to store the time of purchase can i use this as time<48 what is this convention to take it as <48 will it take as hours when we mention this?

Thank YOu..
User avatar
andym01480
Forum Contributor
Posts: 390
Joined: Wed Apr 19, 2006 5:01 pm

Post by andym01480 »

No.

time()
Returns the current time measured in the number of seconds since the Unix Epoch (January 1 1970 00:00:00 GMT).
So you need to check the current time is <= the time from the database + 172800 (which is 48hrs*60mins*60secs!)

Now if you are really smart you can do that as a mysql query. - perhaps someone else will show how. Too early in the morning for me to work that out!
Post Reply