[PHP] Date format from file
Is it possible to read a string from a text file (i.e. 0502031130) and be able to use that in a date function such as: $date = date(dmyHi, strtotime('+28 days)); How would I use that string as the date in the above code? TIA, Ed -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Date format from file
Hi, Thursday, February 6, 2003, 2:41:42 AM, you wrote: ehhc Is it possible to read a string from a text file (i.e. ehhc 0502031130) and be able to use that in a date function such as: ehhc $date = date(dmyHi, strtotime('+28 days)); ehhc How would I use that string as the date in the above code? ehhc TIA, ehhc Ed If you change the format of your string you can do this: $t = 20030205 1530; echo 'New date/time = '.date(d/m/Y H:i,strtotime($t. + 28 days)).'br'; -- regards, Tom -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Date format from file
Is it possible to read a string from a text file (i.e. 0502031130) and be able to use that in a date function such as: $date = date(dmyHi, strtotime('+28 days)); How would I use that string as the date in the above code? What database are you using? You can probably do all of this in your SQL statement if you're using the correct columns. ---John W. Holmes... PHP Architect - A monthly magazine for PHP Professionals. Get your copy today. http://www.phparch.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Date format from file
I'm not using this for any database related function. What I'm trying to do is come up with a method for scheduling processes needed for our company that are run through command line php scripts. I'll be using cron or to run a command that will check the date within the file and see if the process needs to be run on that day and then rewrite the date + 28 days back into the file spawning the process if need be. To the best of my knowledge cron cannot run schedules this way. It can only run on specific days or times outlined directly. Our processes must run every 28 days, not a specific day of the month. If there is any other scheduling system out there that can do this type of thing on Linux/Unix I'd much rather use it than doing it this way. Ed On Wed, 5 Feb 2003, John W. Holmes wrote: Is it possible to read a string from a text file (i.e. 0502031130) and be able to use that in a date function such as: $date = date(dmyHi, strtotime('+28 days)); How would I use that string as the date in the above code? What database are you using? You can probably do all of this in your SQL statement if you're using the correct columns. ---John W. Holmes... PHP Architect - A monthly magazine for PHP Professionals. Get your copy today. http://www.phparch.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Date format from file
I'm not using this for any database related function. What I'm trying to do is come up with a method for scheduling processes needed for our company that are run through command line php scripts. I'll be using cron or to run a command that will check the date within the file and see if the process needs to be run on that day and then rewrite the date + 28 days back into the file spawning the process if need be. To the best of my knowledge cron cannot run schedules this way. It can only run on specific days or times outlined directly. Our processes must run every 28 days, not a specific day of the month. If there is any other scheduling system out there that can do this type of thing on Linux/Unix I'd much rather use it than doing it this way. Sorry, I though I read database in there somewhere. I don't know of another program. As long as you write a unix timestamp or some date format that can be parsed by strtotime(), then you can do it this way. Use fopen()/fread() to get the last time saved in the file. If you're using unix timestamps, just see if the current time is greater than the old timestamp + 28 days... If(time() $old_timestamp + 60*60*24*28) { //run script and save new time(); } ---John W. Holmes... PHP Architect - A monthly magazine for PHP Professionals. Get your copy today. http://www.phparch.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Date format from file (END)
I don't know of another program. As long as you write a unix timestamp or some date format that can be parsed by strtotime(), then you can do it this way. Use fopen()/fread() to get the last time saved in the file. If you're using unix timestamps, just see if the current time is greater than the old timestamp + 28 days... If(time() $old_timestamp + 60*60*24*28) { //run script and save new time(); } ---John W. Holmes... Thanks alot for all the help. Using cron to run the checktime script I can then make sure the process gets run on the exact time it needs to be run along with the exact date in the file. Ed -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php