In PHP, how do I lop off the hours, minutes, and seconds of a time variable and replace it with a random hour, minute, and second?
Thanks,
Andrew
Hey Andrew, hope you are well. :-)
The following PHP function will help in generating random integers.
In this comment, the user has done it for dates. :-)
http://www.php.net/manual/en/function.rand.php#92561
Hope this helps point you in the right direction :-)
Take care.
Thanks Tim,
I guess I made it too complex for myself. I can generate a random hour and minute and second with the rand function as you pointed out. Now I just have to figure out how to replace them in the datetime variable.
Greetings AndrewTraub,
Thank you for letting us know that you have got your question resolved.
If we can be of further assistance please let us know.
Cheers, Joe :-)
Become a member
Responses (3)
Support Chimp — 8th February 2012 (3 months ago) #
Hey Andrew, hope you are well. :-)
The following PHP function will help in generating random integers.
In this comment, the user has done it for dates. :-)
http://www.php.net/manual/en/function.rand.php#92561
Hope this helps point you in the right direction :-)
Take care.
Member — 8th February 2012 (3 months ago) #
Thanks Tim,
I guess I made it too complex for myself. I can generate a random hour and minute and second with the rand function as you pointed out. Now I just have to figure out how to replace them in the datetime variable.
Andrew
Support Kangaroo — 8th February 2012 (3 months ago) #
Greetings AndrewTraub,
Thank you for letting us know that you have got your question resolved.
If we can be of further assistance please let us know.
Cheers, Joe :-)
Become a member