Jump to content

reseting counter


vmicchia

Recommended Posts

I'm not sure if this is the right form I may need to put this in the mySQL forum so apologies if it's in the wrong place. I would however like to do this in php.

 

What I need to do is set up a counter that resets every day at midnight. So it would start with 01 and count up till 12:00AM server time and then reset to 01 for the next day. This is for an ordering system to add a number to the end of any order.

 

Any help is much appreciated. I know it's not much info but I'm not even sure where to begin such a thing.

Link to comment
https://forums.phpfreaks.com/topic/228501-reseting-counter/
Share on other sites

use microtime() - it's a built-in function of PHP that gives you the number of seconds + milleseconds since the UNIX Epoch (1st January 1970) according to the server time. you can use time() for just the seconds but in case someone orders something on the same second you will want microtime to differentiate between the two orders.

 

Although usually you would implement your own unique numbering system.

 

hope this helps

Link to comment
https://forums.phpfreaks.com/topic/228501-reseting-counter/#findComment-1178258
Share on other sites

From what I take from this, you may be wanting date('H:i:s'), which would give you the time of the day according to the server.

 

Example output of "echo date('H:i:s');" would be 16:04:32 (4:04 pm for those of you that can't read 24-hour)

Link to comment
https://forums.phpfreaks.com/topic/228501-reseting-counter/#findComment-1178608
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.