RE: [PHP] unix timestamp
The attached class is a date utility that I created a long time ago. It parses out SQL dates, does differences, and specific to your needs, you can use dateAdjust() to move a unix timestamp by a number of seconds, minutes, hours, days, months, quarters, years or centuries. You should be able to either employ this class, or simply look through the code to find the answers to most of your date woes. The only thing this class doesn't do, is account for leap years, when working with quantities that span multiple months. (never got around to this yet, suppose I will need to before 2004!) Attached is also a short readme to explain what the functions are and what they do (the code itself is also well commented). Best wishes! Michael phpzen -Original Message- From: andy [mailto:[EMAIL PROTECTED]] Sent: Friday, September 06, 2002 4:50 AM To: [EMAIL PROTECTED] Subject: [PHP] unix timestamp Hi everybody, I am trying to create a unix timestamp which dates back a certain amount of days. Lets say I would like to have a unix timestamp from 7 days ago. what I tryed is just to subtract values since this are counted s since the start of the unix epoche, but this does not work in cases like the switch of months. Has anybody an idea how to do that? Thanx, Andy -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] formatting a filename
Ereg() would be an excellent choice. To move a step further, although it is a little more complex to become familiar with, the perl regular expressions are considerably faster and more efficient for anything with an expression, and str_replace() is faster yet, if replacing a simple string. Thus, it would probably be best to use: $clean_term = str_replace( , _, $term); // replace spaces with _ $clean_term = preg_replace(@[^a-zA-Z0-9_.]@, , $term); // remove any non-alphanumeric chars There is an excellent article somewhere that gives some benchmark times for the various methods... Anyone know where this is? I can't seem to find it anymore. However, I remember the basic concept: on a given string, preg_replace ran about 1 second, ereg_replace ran about 4 seconds, and str_replace ran about .2 seconds. See these docs for info about syntax: http://www.php.net/manual/en/function.preg-replace.php http://www.php.net/manual/en/function.str-replace.php http://www.php.net/manual/en/function.ereg-replace.php Best wishes Michael phpzen -Original Message- From: Rodolfo Gonzalez [mailto:[EMAIL PROTECTED]] Sent: Thursday, September 05, 2002 9:34 AM To: Javier Montserat Cc: [EMAIL PROTECTED] Subject: Re: [PHP] formatting a filename On Thu, 5 Sep 2002, Javier Montserat wrote: i want to format the filename of an uploaded file as follows :- -- replace blankspace with _ -- remove any illegal characters. Which string functions should I use to do this? http://www.php.net/manual/en/function.ereg.php http://www.php.net/manual/en/function.ereg.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] How do I get milliseconds?
If you are looking for milliseconds on the current time, see the examples on microtime(): http://www.php.net/manual/en/function.microtime.php Here is a summary of how to get milliseconds: list($usec, $sec) = explode( ,microtime()); $milliseconds = (((float)$usec/1000) + (float)$sec); I haven't tested this out, but it looks right. Michael phpzen Richardson -Original Message- From: DonPro [mailto:[EMAIL PROTECTED]] Sent: Wednesday, September 04, 2002 11:47 AM To: php list Subject: [PHP] How do I get milliseconds? Using the following code, date(His) I get the hours, minutes and seconds. Is there a way to extend this so that I get the milliseconds too? Thanks, Don -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Returning Rows Question
While( ) { ... $color = ($color == FF)? EAEAEA : FF; print td bgcolor='#$color'\n; ... } -Original Message- From: Christopher J. Crane [mailto:[EMAIL PROTECTED]] Sent: Wednesday, September 04, 2002 3:56 PM To: [EMAIL PROTECTED] Subject: [PHP] Returning Rows Question How do you alternate colors of the rows in a table inside a while statement when dealing with the output of data from a DB. I am sure it's something simple but I keep getting into some really long math thing... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Set Variable to Multiple Lines
I've been searching for this old php feature (perhaps it was deprecated), and can't get the right keywords to look it up. There was a way, similar to the perl method shown below, to set multiple lines of data equal to a variable. (in perl) $variable = __SOME_HEADER_HERE__ Put whatever is desired here, including $variables. Just end it with this: __SOME_HEADER_HERE__; Anyone know what this is for PHP? Best wishes Michael Richardson Web Developer (520) 529-2000 [EMAIL PROTECTED] // http://www.mdausa.org // ..very few phenomena can pull someone out of Deep Hack Mode, with two noted exceptions: being struck by lightning, or worse, your *computer* being struck by lightning. -- Matt Welsh