Re: [PHP] Date question
William Stokes wrote: Hello, I have a datetime column in MySQL DB. How can I match to that column from php code if I only have the date information available. 2006-02-24 12:00:00 against2006-02-24 This might be more SQL question sorry about that. Thanks -Will use date_format(%Y-%m-%d,'date_column') in the sql http://dev.mysql.com/doc/refman/5.0/en/date-and-time-functions.html -- Sumeet Shroff http://www.prateeksha.com Web Design and Ecommerce Development, Mumbai India -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Date question
I have a datetime column in MySQL DB. How can I match to that column from php code if I only have the date information available. 2006-02-24 12:00:00 against2006-02-24 This might be more SQL question sorry about that. use date_format(%Y-%m-%d,'date_column') in the sql http://dev.mysql.com/doc/refman/5.0/en/date-and-time-functions.html The above is likely one of the more elegant solutions. But if you wanted to do this completely in PHP, you could do something like: pseudocode $phpDate = '2006-02-24'; $rowData = mysql_fetch_assoc( $yourQuery ); if( date( 'Y-m-d', strtotime( $rowData['MySQLDate'] )) == $phpDate )) { echo 'Dates match!'; } /pseudocode thnx, Chris -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] date(H, $datevalue) always adds an hour?
Hi All, Wondering if anyone can help me work out why date(H) always adds an hour? I'm *assuming* it thinks it should be compensating for Daylight Saving Time (though I'd be just as willing to believe that it's caused by something else), however we don't observe DST in Queensland, Australia. Making matters a little more complex, while my local machine shouldn't be compensating for DST (if that's what's happening), my remote machine (based in Florida somewhere, I think) should, when applicable. So, just to explain a little better. Let's say the clock on my computer reads 7:00pm. If I do echo date(H); it will output 20, instead of 19. The same thing happens if I take a date value from my mysql database. $sql = SELECT UNIX_TIMESTAMP(datecreated) AS unx_date FROM mytable; $rs = mysql_query($sql); $row = mysql_fetch_object($rs); echo date(H, $row-unx_date); If the above record contained the value '2006-01-10 19:00', the code would output 20 instead of 19. Can anyone help me figure out how to accommodate for this? Much warmth, Murray -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] date(H, $datevalue) always adds an hour?
Murray, What do you get if you print date(T)? David -- David Grant http://www.grant.org.uk/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] date(H, $datevalue) always adds an hour?
On 20/01/2006 8:39 PM, David Grant wrote: Murray, What do you get if you print date(T)? David Hi David, I get EST, which I assume is Eastern Savings Time? If that's the case, any idea where I change this value so that it only affects my local machine? Much warmth, Murray -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] date(H, $datevalue) always adds an hour?
Murray, As far as I know, Queensland is in EST (Eastern Standard Time), so that is the correct value. Are you using the same machine or is it remote? David -- David Grant http://www.grant.org.uk/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] date(H, $datevalue) always adds an hour?
On 20/01/2006 8:48 PM, David Grant wrote: Murray, As far as I know, Queensland is in EST (Eastern Standard Time), so that is the correct value. Are you using the same machine or is it remote? David Hi David, I'm currently working entirely on my local (Queensland) machine. The remote machine only becomes an issue when I'm finished putting the site together. Thanks for giving this some thought... Murray -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] date(H, $datevalue) always adds an hour?
Murray, I can't think what else it might be. Sorry! David -- David Grant http://www.grant.org.uk/ http://pear.php.net/package/File_Ogg0.2.1 http://pear.php.net/package/File_XSPF 0.1.0 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] date(H, $datevalue) always adds an hour?
David Grant wrote: Murray, I can't think what else it might be. Sorry! David What does date(I, $datevalue) return? (it's a capital 'i') I guess you already checked out this page... http://php.net/date -- tradeOver | http://www.tradeover.net ...ready to become the King of the World? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] date(H, $datevalue) always adds an hour?
On Fri, January 20, 2006 4:24 am, Murray @ PlanetThoughtful wrote: Wondering if anyone can help me work out why date(H) always adds an hour? I'm *assuming* it thinks it should be compensating for Daylight Saving Time (though I'd be just as willing to believe that it's caused by something else), however we don't observe DST in Queensland, Australia. Making matters a little more complex, while my local machine shouldn't be compensating for DST (if that's what's happening), my remote machine (based in Florida somewhere, I think) should, when applicable. So, just to explain a little better. Let's say the clock on my computer reads 7:00pm. If I do echo date(H); it will output 20, instead of 19. The same thing happens if I take a date value from my mysql database. $sql = SELECT UNIX_TIMESTAMP(datecreated) AS unx_date FROM mytable; $rs = mysql_query($sql); $row = mysql_fetch_object($rs); echo date(H, $row-unx_date); If the above record contained the value '2006-01-10 19:00', the code would output 20 instead of 19. Can anyone help me figure out how to accommodate for this? Ah, the joys of time-zones, and daylight savings. I'd like to kill the guy that thought up daylight savings. Not only does it depend on the machine's location, and where the machine thinks it's located (you could lie to your computer, you know) but also the 'locale' settings and the BIOS UTC setting, and the server's settings in the OS and/or NTP client and... Oh, plus with MySQL, there are settings that can convince MySQL to not pay attention to the OS about its locale/zone settings and to do someting else instead. Tracking down where the fault lies is generally not fun But at least now you know where to look :-) I usually throw my hands up in despair and just add/subtract whatever, and then check it again when daylight savings changes over and see if it still works -- Because I have zero control over any of the settings on a shared server anyway. And what's up with these countries with time-zones offset by 15 minutes? What were they thinking? -- Like Music? http://l-i-e.com/artists.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] date(H, $datevalue) always adds an hour?
Hi, On Jan 20, 2006, at 2:24 AM, Murray @ PlanetThoughtful wrote: Can anyone help me figure out how to accommodate for this? Not sure if this will help, but: # Set time zone: putenv('TZ=US/Pacific'); // I am on west-coast, my servers are on east, if not for this code the timestamp used in my script will reley upon the server time. This line of code will over-ride server time. Maybe look-up putenv on php.net and read-up in the comments section, I usually find good info that way. Gl, Cheers, Micky -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] date processing needed in form
Hello - I need to create a form that allows the user to select a Month, Day and Year. I am also new to PHP and am wondering if there is a way for me to display the contents of the Select list box (for the Day) based on the Month that is selected (and Year), so that the valid number of days for the month ( year?) displays. For all of our other forms, we use CGI to handle our standard forms validation, and was hoping to handle more complex validation within PHP prior to sending the entire contents of my form to our standard CGI validation routine. I know that I could use the Checkdate function once the entire date is selected, but thought there might be an easier/more efficient way of handling this and also not sure how to reference Checkdate prior to Submitting my form to the CGI routine. I also was not sure if this was something that is handled easier using Javascript? Any help/examples, etc. would be greatly appreciated! Thanks!! Sue -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] date processing needed in form
I need to create a form that allows the user to select a Month, Day and Year. I am also new to PHP and am wondering if there is a way for me to display the contents of the Select list box (for the Day) based on the Month that is selected (and Year), so that the valid number of days for the month ( year?) displays. Since PHP is server-side, a more elegant solution could be achieved using javascript. In order to do this with PHP, your script would have to make the trip back to the server after the month was entered to calculate the valid day. JM -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Date Function Questions
the date taken is the same as the local time of the webserver. So if it changes that maybe the server admin's are changing it? -- http://esu.proyectoanonimo.com http://www.proyectoanonimo.com
[PHP] Date Function Questions
This maybe a dumb questions, but in php where is the information taken from for the date() function? Is it pulled through Apache or the hardware or in the php.ini file? I am having an issue to where the time arbitraly changed one day from PST to CST.
[PHP] R: [PHP] Date Function Questions
afaik it's the system time. Cheers En3pY Sebastian Konstanty Zdrojewski URL: http://www.en3py.net/ E-Mail: [EMAIL PROTECTED] Le informazioni contenute in questo messaggio sono riservate e confidenziali. Il loro utilizzo è consentito esclusivamente al destinatario del messaggio, per le finalità indicate nel messaggio stesso. Qualora Lei non fosse la persona a cui il presente messaggio è destinato, La invito ad eliminarlo dal Suo Sistema ed a distruggere le varie copie o stampe, dandone gentilmente comunicazione. Ogni utilizzo improprio è contrario ai principi del D.lgs 196/03 e alla legislazione Europea (Direttiva 2002/58/CE). -Messaggio originale- Da: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Inviato: lunedì 12 dicembre 2005 6.57 A: PHP-General Oggetto: [PHP] Date Function Questions This maybe a dumb questions, but in php where is the information taken from for the date() function? Is it pulled through Apache or the hardware or in the php.ini file? I am having an issue to where the time arbitraly changed one day from PST to CST. -- No virus found in this incoming message. Checked by AVG Free Edition. Version: 7.1.371 / Virus Database: 267.13.13/197 - Release Date: 09/12/2005 smime.p7s Description: S/MIME cryptographic signature
[PHP] Re: R: [PHP] Date Function Questions
Is the system time through Linux, Apache or through the php.ini file? On 12/11/05, Sebastian En3pY Zdrojewski [EMAIL PROTECTED] wrote: afaik it's the system time. Cheers En3pY Sebastian Konstanty Zdrojewski URL: http://www.en3py.net/ E-Mail: [EMAIL PROTECTED] Le informazioni contenute in questo messaggio sono riservate e confidenziali. Il loro utilizzo è consentito esclusivamente al destinatario del messaggio, per le finalità indicate nel messaggio stesso. Qualora Lei non fosse la persona a cui il presente messaggio è destinato, La invito ad eliminarlo dal Suo Sistema ed a distruggere le varie copie o stampe, dandone gentilmente comunicazione. Ogni utilizzo improprio è contrario ai principi del D.lgs 196/03 e alla legislazione Europea (Direttiva 2002/58/CE). -Messaggio originale- Da: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Inviato: lunedì 12 dicembre 2005 6.57 A: PHP-General Oggetto: [PHP] Date Function Questions This maybe a dumb questions, but in php where is the information taken from for the date() function? Is it pulled through Apache or the hardware or in the php.ini file? I am having an issue to where the time arbitraly changed one day from PST to CST. -- No virus found in this incoming message. Checked by AVG Free Edition. Version: 7.1.371 / Virus Database: 267.13.13/197 - Release Date: 09/12/2005 -- ** The content of this e-mail message and any attachments are confidential and may be legally privileged, intended solely for the addressee. If you are not the intended recipient, be advised that any use, dissemination, distribution, or copying of this e-mail is strictly prohibited. If you receive this message in error, please notify the sender immediately by reply email and destroy the message and its attachments. *
RE: [PHP] Re: R: [PHP] Date Function Questions
System Time Is the system time through Linux, Apache or through the php.ini file? On 12/11/05, Sebastian En3pY Zdrojewski [EMAIL PROTECTED] wrote: afaik it's the system time. Cheers En3pY Sebastian Konstanty Zdrojewski URL: http://www.en3py.net/ E-Mail: [EMAIL PROTECTED] Le informazioni contenute in questo messaggio sono riservate e confidenziali. Il loro utilizzo è consentito esclusivamente al destinatario del messaggio, per le finalità indicate nel messaggio stesso. Qualora Lei non fosse la persona a cui il presente messaggio è destinato, La invito ad eliminarlo dal Suo Sistema ed a distruggere le varie copie o stampe, dandone gentilmente comunicazione. Ogni utilizzo improprio è contrario ai principi del D.lgs 196/03 e alla legislazione Europea (Direttiva 2002/58/CE). -Messaggio originale- Da: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Inviato: lunedì 12 dicembre 2005 6.57 A: PHP-General Oggetto: [PHP] Date Function Questions This maybe a dumb questions, but in php where is the information taken from for the date() function? Is it pulled through Apache or the hardware or in the php.ini file? I am having an issue to where the time arbitraly changed one day from PST to CST. -- No virus found in this incoming message. Checked by AVG Free Edition. Version: 7.1.371 / Virus Database: 267.13.13/197 - Release Date: 09/12/2005 -- ** The content of this e-mail message and any attachments are confidential and may be legally privileged, intended solely for the addressee. If you are not the intended recipient, be advised that any use, dissemination, distribution, or copying of this e-mail is strictly prohibited. If you receive this message in error, please notify the sender immediately by reply email and destroy the message and its attachments. * -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] date comparisions...
I am confused... probably because of lack of sleep. Anyway... I have code that looks like this: if ($discountResult[dateexpired] date(U)) { //dosomething } else { //do something else } Using Epoch obviously Anyway... it's supposed to read: IF the expired date is past the current date... disallow dosomething otherwise... let it go. I set the expire date to be Sept 30, 2005 and obviously today is the current date but for some reason the dosomething is being allowed. Do I have the operators mixed up here? Works is I reverse the operator but shouldn't it work as I have it? Thanks all. Appreciate the clarrification. A -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] date comparisions...
Hi aaronjw, Friday, October 7, 2005, 7:34:11 PM, you wrote: if ($discountResult[dateexpired] date(U)) { //dosomething } else { //do something else } Anyway... it's supposed to read: IF the expired date is past the current date... disallow dosomething otherwise... let it go. I set the expire date to be Sept 30, 2005 and obviously today is the current date but for some reason the dosomething is being allowed. Start with the obvious - what actually IS the value of $discountResult[dateexpired]? var_dump it out and have a look. Check you are comparing like with like. You're also not performing a strict comparison, so string conversion could be going on here. The other obvious fact is that if dateexpired is less than *right now*, it'll always dosomething ! :) Cheers, Rich -- Zend Certified Engineer http://www.launchcode.co.uk -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] date comparisions...
Hi Rich, Thanks for your reply. dateexpired is: 1128052800 which translates into: 2005-09-30 00:00:00 Basically, I'm just trying to figure out when the dateexpired is. IF it is past the current date then I am erroring out and if it's under the current date... I'm allowing the transaction. I would assume the following: if (2005-09-30 00:00:00 2005-10-07 00:00:00) it should error out, no? Thanks! Aaron Hi aaronjw, Start with the obvious - what actually IS the value of $discountResult[dateexpired]? var_dump it out and have a look. Check you are comparing like with like. You're also not performing a strict comparison, so string conversion could be going on here. The other obvious fact is that if dateexpired is less than *right now*, it'll always dosomething ! :) Cheers, Rich -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re[2]: [PHP] date comparisions...
Hi, Friday, October 7, 2005, 7:55:45 PM, you wrote: dateexpired is: 1128052800 which translates into: 2005-09-30 00:00:00 Basically, I'm just trying to figure out when the dateexpired is. IF it is past the current date then I am erroring out and if it's under the current date... I'm allowing the transaction. I would assume the following: if (2005-09-30 00:00:00 2005-10-07 00:00:00) it should error out, no? Not given your logic above, no. You said If it is past the current date then I am erroring out, therefore 2005-09-30 00:00:00 2005-10-07 00:00:00 will NEVER error out, because it will never be greater than the current timestamp in seconds. A = 2005-09-03 = 1,128,052,800 B = 2005-10-07 = 1,128,713,278 (approx, that's actually the value now) So A will never be greater than B, hence you're always allowing the transaction. Cheers, Rich -- Zend Certified Engineer http://www.launchcode.co.uk -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] mysql/php date functions..
hi... can anybody point me to a good/basic tutorial (tested) for php/mysql date functions... basically, i want to store a date/time in a column, and be able to read it, manipulate it, and update the table. i've seen various articles/sample code, but i'm looking for something that i cna pretty much rewrite and use without having to do a lot of initial testing.. if i create the functions myself, i'm going to need to do initial testing to make sure i haven't screwed something up, and i'm on a time crunch!! thanks -bruce [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] mysql/php date functions..
-Original Message- From: bruce [mailto:[EMAIL PROTECTED] Sent: Monday, September 26, 2005 11:12 AM To: php-general@lists.php.net Subject: [PHP] mysql/php date functions.. hi... can anybody point me to a good/basic tutorial (tested) for php/mysql date functions... basically, i want to store a date/time in a column, and be able to read it, manipulate it, and update the table. i've seen various articles/sample code, but i'm looking for something that i cna pretty much rewrite and use without having to do a lot of initial testing.. if i create the functions myself, i'm going to need to do initial testing to make sure i haven't screwed something up, and i'm on a time crunch!! Hi Bruce! MySQL and PHP both have extensive built-in date functions that are clearly documented and extraordinarily easy to use. For the vast majority of situations, there is no need to manually write any custom date-handling code. The decision to use MySQL or PHP to manipulate a date for a given instance depends largely on the particulars of that situation. For instance, if you want to increment a MySQL date column by one day, it would likely be better to use the MySQL date functions to do it, because to use PHP, you have to read the date, manipulate it, then write it back, whereas if you use a SQL statement, you can do it with one DB call. See: http://www.php.net/datetime http://dev.mysql.com/doc/mysql/en/date-and-time-functions.html Cheers! JM -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] mysql/php date functions..
Jim Moseby wrote: Hi Bruce! MySQL and PHP both have extensive built-in date functions that are clearly documented and extraordinarily easy to use. For the vast majority of situations, there is no need to manually write any custom date-handling code. The decision to use MySQL or PHP to manipulate a date for a given instance depends largely on the particulars of that situation. For instance, if you want to increment a MySQL date column by one day, it would likely be better to use the MySQL date functions to do it, because to use PHP, you have to read the date, manipulate it, then write it back, whereas if you use a SQL statement, you can do it with one DB call. See: http://www.php.net/datetime http://dev.mysql.com/doc/mysql/en/date-and-time-functions.html Cheers! Just my 0.02 euros. When I need to use dates in PHP *and* MySQL I usually use the UNIX timestamp (seconds since the epoch, that is, the PHP http://php.net/time output). This way I can (quite) easily calculate date differences etc. (usually all the calculations are done in PHP, also when building SQL queries). As I said, just my 0.02 euros... Cheers Silvio -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] mysql/php date functions..
how can i create a mysql sql statement to insert a php 'time()' into mysql? i've got the mysql var 't1, timestamp' but i can't figure out how to do an insert $q = time(); $sql = sprintf(insert into foo (id, ctime) values(%d, %???), $id, $q); can't figure out how to get this to work... if i create a sql statement and run it directly within mysql, --insert into foo (id, ctime) values(2, NOW()); this works.. but i can't figure out how to create the sql using the php time() function and getting the insert from the php app... so what's the basic part i'm missing??!! -bruce -Original Message- From: Silvio Porcellana [mailto:[EMAIL PROTECTED] Sent: Monday, September 26, 2005 8:51 AM To: php-general@lists.php.net Subject: Re: [PHP] mysql/php date functions.. Jim Moseby wrote: Hi Bruce! MySQL and PHP both have extensive built-in date functions that are clearly documented and extraordinarily easy to use. For the vast majority of situations, there is no need to manually write any custom date-handling code. The decision to use MySQL or PHP to manipulate a date for a given instance depends largely on the particulars of that situation. For instance, if you want to increment a MySQL date column by one day, it would likely be better to use the MySQL date functions to do it, because to use PHP, you have to read the date, manipulate it, then write it back, whereas if you use a SQL statement, you can do it with one DB call. See: http://www.php.net/datetime http://dev.mysql.com/doc/mysql/en/date-and-time-functions.html Cheers! Just my 0.02 euros. When I need to use dates in PHP *and* MySQL I usually use the UNIX timestamp (seconds since the epoch, that is, the PHP http://php.net/time output). This way I can (quite) easily calculate date differences etc. (usually all the calculations are done in PHP, also when building SQL queries). As I said, just my 0.02 euros... Cheers Silvio -- 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] mysql/php date functions..
bruce wrote: how can i create a mysql sql statement to insert a php 'time()' into mysql? i've got the mysql var 't1, timestamp' but i can't figure out how to do an insert $q = time(); $sql = sprintf(insert into foo (id, ctime) values(%d, %???), $id, $q); can't figure out how to get this to work... if i create a sql statement and run it directly within mysql, --insert into foo (id, ctime) values(2, NOW()); this works.. but i can't figure out how to create the sql using the php time() function and getting the insert from the php app... so what's the basic part i'm missing??!! -bruce $sql = INSERT INTO db.table ( id, ctime ) VALUES ( . $id . , . time() . ); -- John C. Nichel ÜberGeek KegWorks.com 716.856.9675 [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] mysql/php date functions..
thanks... but that's not it john... i'm not worried about creating the sql_statement in the php... i'm concerned that i can't seem to craft/create a basic sql cmd within mysql to get a value (other than NOW()) to work... if i do (from mysql) -- insert into foo (id, time) values (2, 33), it doesn't work... if i -- insert into foo (id, time) values (2, NOW()), it works!!... my question is why??? -bruce -Original Message- From: John Nichel [mailto:[EMAIL PROTECTED] Sent: Monday, September 26, 2005 11:00 AM To: php-general@lists.php.net Subject: Re: [PHP] mysql/php date functions.. bruce wrote: how can i create a mysql sql statement to insert a php 'time()' into mysql? i've got the mysql var 't1, timestamp' but i can't figure out how to do an insert $q = time(); $sql = sprintf(insert into foo (id, ctime) values(%d, %???), $id, $q); can't figure out how to get this to work... if i create a sql statement and run it directly within mysql, --insert into foo (id, ctime) values(2, NOW()); this works.. but i can't figure out how to create the sql using the php time() function and getting the insert from the php app... so what's the basic part i'm missing??!! -bruce $sql = INSERT INTO db.table ( id, ctime ) VALUES ( . $id . , . time() . ); -- John C. Nichel ÜberGeek KegWorks.com 716.856.9675 [EMAIL PROTECTED] -- 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] mysql/php date functions..
along the same way... why can't i see the timestamp designation (ie the double/int) instead of the date-time format when i look at the timestmp var when i do a 'select * from t1' within mysql?? arrgghh! -bruce -Original Message- From: John Nichel [mailto:[EMAIL PROTECTED] Sent: Monday, September 26, 2005 11:00 AM To: php-general@lists.php.net Subject: Re: [PHP] mysql/php date functions.. bruce wrote: how can i create a mysql sql statement to insert a php 'time()' into mysql? i've got the mysql var 't1, timestamp' but i can't figure out how to do an insert $q = time(); $sql = sprintf(insert into foo (id, ctime) values(%d, %???), $id, $q); can't figure out how to get this to work... if i create a sql statement and run it directly within mysql, --insert into foo (id, ctime) values(2, NOW()); this works.. but i can't figure out how to create the sql using the php time() function and getting the insert from the php app... so what's the basic part i'm missing??!! -bruce $sql = INSERT INTO db.table ( id, ctime ) VALUES ( . $id . , . time() . ); -- John C. Nichel ÜberGeek KegWorks.com 716.856.9675 [EMAIL PROTECTED] -- 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] mysql/php date functions..
bruce mailto:[EMAIL PROTECTED] on Monday, September 26, 2005 11:13 AM said: i'm concerned that i can't seem to craft/create a basic sql cmd within mysql to get a value (other than NOW()) to work... [snip] my question is why??? MySQL timestamps are different from UNIX timestamps. Chris. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] mysql/php date functions..
bruce wrote: thanks... but that's not it john... i'm not worried about creating the sql_statement in the php... i'm concerned that i can't seem to craft/create a basic sql cmd within mysql to get a value (other than NOW()) to work... if i do (from mysql) -- insert into foo (id, time) values (2, 33), it doesn't work... if i -- insert into foo (id, time) values (2, NOW()), it works!!... my question is why??? Without knowing the structure of your table, my guess is that the column time is expecting a valid timestamp, and 33 is not a valid MySQL timestamp. -- John C. Nichel ÜberGeek KegWorks.com 716.856.9675 [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] mysql/php date functions..
but that still doesn't explain why i can't slam some value directly into the timestamp var within the mysql tbl... -Original Message- From: Chris W. Parker [mailto:[EMAIL PROTECTED] Sent: Monday, September 26, 2005 11:15 AM To: php-general@lists.php.net Subject: RE: [PHP] mysql/php date functions.. bruce mailto:[EMAIL PROTECTED] on Monday, September 26, 2005 11:13 AM said: i'm concerned that i can't seem to craft/create a basic sql cmd within mysql to get a value (other than NOW()) to work... [snip] my question is why??? MySQL timestamps are different from UNIX timestamps. Chris. -- 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] mysql/php date functions..
john... that appears to be it!! although i would have assumes it would have done a most significant bit fill with 0's... so my question also comes down to .. do i use the php date functions for date/time manipulation.. or do i use the mysql functions any thoughts/suggestions... -bruce -Original Message- From: John Nichel [mailto:[EMAIL PROTECTED] Sent: Monday, September 26, 2005 11:19 AM To: php-general@lists.php.net Subject: Re: [PHP] mysql/php date functions.. bruce wrote: thanks... but that's not it john... i'm not worried about creating the sql_statement in the php... i'm concerned that i can't seem to craft/create a basic sql cmd within mysql to get a value (other than NOW()) to work... if i do (from mysql) -- insert into foo (id, time) values (2, 33), it doesn't work... if i -- insert into foo (id, time) values (2, NOW()), it works!!... my question is why??? Without knowing the structure of your table, my guess is that the column time is expecting a valid timestamp, and 33 is not a valid MySQL timestamp. -- John C. Nichel ÜberGeek KegWorks.com 716.856.9675 [EMAIL PROTECTED] -- 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] mysql/php date functions..
bruce wrote: john... that appears to be it!! although i would have assumes it would have done a most significant bit fill with 0's... so my question also comes down to .. do i use the php date functions for date/time manipulation.. or do i use the mysql functions any thoughts/suggestions... -bruce Personal preference I guess. Me, I use UNIX timestamps. -- John C. Nichel ÜberGeek KegWorks.com 716.856.9675 [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] mysql/php date functions..
-Original Message- From: bruce [mailto:[EMAIL PROTECTED] Sent: Monday, September 26, 2005 2:46 PM To: 'John Nichel'; php-general@lists.php.net Subject: RE: [PHP] mysql/php date functions.. john... that appears to be it!! although i would have assumes it would have done a most significant bit fill with 0's... so my question also comes down to .. do i use the php date functions for date/time manipulation.. or do i use the mysql functions any thoughts/suggestions... -bruce That depends largely on the situation. For instance, if you want to increment a date in a MySQL table, you would likely do it with a MySQL statement, because to do it in PHP, you need to do a read, then add the day, then a write, (two DB calls). With MySQL, you would just do something like: update `mytable` set 'columnname` date_add(columnname, interval 1 day); One call to the DB instead of two, much more efficient. There are many instances where you would want to use PHP to manipulate dates too, depending on their circumstances. JM -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] mysql/php date functions..
so you play with the time/date vars on the php side, and then simply store them in the mysql tbl as a int(10)... or do you actually store the vars in the mysql timestamp... and then use the mysql date/time functions... ie. how would you do the following... get a date (date1) get a date (date2) store the date1/time in mysql add the date1 + date2 and store the result in mysql read the result from mysql, with the result being in the year/month/date format -- or, would you just get the unix_timestamp representation of the dates, and store the 10 int formats in the mysql tbl. you could then extract/select the date information from the tbls, and do all the date calculations in php... the downside to this is that you'd have to convert all the date information from mysql to a human readable format... thoughts/comments/etc... -bruce -Original Message- From: John Nichel [mailto:[EMAIL PROTECTED] Sent: Monday, September 26, 2005 11:48 AM To: php-general@lists.php.net Subject: Re: [PHP] mysql/php date functions.. bruce wrote: john... that appears to be it!! although i would have assumes it would have done a most significant bit fill with 0's... so my question also comes down to .. do i use the php date functions for date/time manipulation.. or do i use the mysql functions any thoughts/suggestions... -bruce Personal preference I guess. Me, I use UNIX timestamps. -- John C. Nichel ÜberGeek KegWorks.com 716.856.9675 [EMAIL PROTECTED] -- 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] mysql/php date functions..
or.. better yet. if i do a php - time(), i get a unix_timestamp var. how do you guys store this in mysql. you can't simply do an insert into a mysql/timestamp var. so how do you convert it? also, once you have the mysql tbl, how do you go from the mysql timestamp var - the php var? thanks bruce -Original Message- From: bruce [mailto:[EMAIL PROTECTED] Sent: Monday, September 26, 2005 12:38 PM To: 'John Nichel'; php-general@lists.php.net Subject: RE: [PHP] mysql/php date functions.. so you play with the time/date vars on the php side, and then simply store them in the mysql tbl as a int(10)... or do you actually store the vars in the mysql timestamp... and then use the mysql date/time functions... ie. how would you do the following... get a date (date1) get a date (date2) store the date1/time in mysql add the date1 + date2 and store the result in mysql read the result from mysql, with the result being in the year/month/date format -- or, would you just get the unix_timestamp representation of the dates, and store the 10 int formats in the mysql tbl. you could then extract/select the date information from the tbls, and do all the date calculations in php... the downside to this is that you'd have to convert all the date information from mysql to a human readable format... thoughts/comments/etc... -bruce -Original Message- From: John Nichel [mailto:[EMAIL PROTECTED] Sent: Monday, September 26, 2005 11:48 AM To: php-general@lists.php.net Subject: Re: [PHP] mysql/php date functions.. bruce wrote: john... that appears to be it!! although i would have assumes it would have done a most significant bit fill with 0's... so my question also comes down to .. do i use the php date functions for date/time manipulation.. or do i use the mysql functions any thoughts/suggestions... -bruce Personal preference I guess. Me, I use UNIX timestamps. -- John C. Nichel ÜberGeek KegWorks.com 716.856.9675 [EMAIL PROTECTED] -- 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 General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] mysql/php date functions..
bruce wrote: or.. better yet. if i do a php - time(), i get a unix_timestamp var. how do you guys store this in mysql. you can't simply do an insert into a mysql/timestamp var. so how do you convert it? I don't convert it. I store the UNIX timestamp in an INT(11) column. also, once you have the mysql tbl, how do you go from the mysql timestamp var - the php var? Since I keep it in the UNIX timestamp format, there's no converting between the two. -- John C. Nichel ÜberGeek KegWorks.com 716.856.9675 [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] mysql/php date functions..
John Nichel mailto:[EMAIL PROTECTED] on Monday, September 26, 2005 12:43 PM said: I don't convert it. I store the UNIX timestamp in an INT(11) column. This is going to be a basic question I'm sure but why INT and not VARCHAR? Is it simply because a timestamp is a number? Chris. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] mysql/php date functions..
Read up on mysql date types and functions. You can convert a unix timestamp to a mysql date with the FROM_UNIXTIME() function. If you want to store as unix timestamp, store it in an int field. To use mysql date functions on it, use the FROM_UNIXTIME() function. If you want to store dates in mysql timestamp fields, use in a select statement a) UNIX_TIMESTAMP() or b) DATE_FORMAT() to a) convert to unix timestamp and process with PHP or b) format date for output. http://dev.mysql.com/doc/mysql/en/date-and-time-types.html http://dev.mysql.com/doc/mysql/en/date-and-time-functions.html kgt bruce wrote: or.. better yet. if i do a php - time(), i get a unix_timestamp var. how do you guys store this in mysql. you can't simply do an insert into a mysql/timestamp var. so how do you convert it? also, once you have the mysql tbl, how do you go from the mysql timestamp var - the php var? thanks bruce -Original Message- From: bruce [mailto:[EMAIL PROTECTED] Sent: Monday, September 26, 2005 12:38 PM To: 'John Nichel'; php-general@lists.php.net Subject: RE: [PHP] mysql/php date functions.. so you play with the time/date vars on the php side, and then simply store them in the mysql tbl as a int(10)... or do you actually store the vars in the mysql timestamp... and then use the mysql date/time functions... ie. how would you do the following... get a date (date1) get a date (date2) store the date1/time in mysql add the date1 + date2 and store the result in mysql read the result from mysql, with the result being in the year/month/date format -- or, would you just get the unix_timestamp representation of the dates, and store the 10 int formats in the mysql tbl. you could then extract/select the date information from the tbls, and do all the date calculations in php... the downside to this is that you'd have to convert all the date information from mysql to a human readable format... thoughts/comments/etc... -bruce -Original Message- From: John Nichel [mailto:[EMAIL PROTECTED] Sent: Monday, September 26, 2005 11:48 AM To: php-general@lists.php.net Subject: Re: [PHP] mysql/php date functions.. bruce wrote: john... that appears to be it!! although i would have assumes it would have done a most significant bit fill with 0's... so my question also comes down to .. do i use the php date functions for date/time manipulation.. or do i use the mysql functions any thoughts/suggestions... -bruce Personal preference I guess. Me, I use UNIX timestamps. -- John C. Nichel ÜberGeek KegWorks.com 716.856.9675 [EMAIL PROTECTED] -- 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 General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] mysql/php date functions..
Chris W. Parker wrote: John Nichel mailto:[EMAIL PROTECTED] on Monday, September 26, 2005 12:43 PM said: I don't convert it. I store the UNIX timestamp in an INT(11) column. This is going to be a basic question I'm sure but why INT and not VARCHAR? Is it simply because a timestamp is a number? Yep. Course, I may be doing it wrong. Wouldn't be the first time. ;) -- John C. Nichel ÜberGeek KegWorks.com 716.856.9675 [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] mysql/php date functions..
Hi The PHP time() function returns the number of seconds since the Unix epoch (Jan 1 1970 midnight) whereas MySQL uses a readable datestamp See here: http://dev.mysql.com/doc/mysql/en/datetime.html for the MySQL date, time and date/time types and here http://uk.php.net/manual/en/function.time.php for time()... instead of using time(), use date() and format it for MySQL http://uk.php.net/manual/en/function.date.php That will allow you to use and in the SQL statements HTH Chrome http://www.chrome.me.uk -Original Message- From: bruce [mailto:[EMAIL PROTECTED] Sent: 26 September 2005 19:46 To: 'John Nichel'; php-general@lists.php.net Subject: RE: [PHP] mysql/php date functions.. john... that appears to be it!! although i would have assumes it would have done a most significant bit fill with 0's... so my question also comes down to .. do i use the php date functions for date/time manipulation.. or do i use the mysql functions any thoughts/suggestions... -bruce -Original Message- From: John Nichel [mailto:[EMAIL PROTECTED] Sent: Monday, September 26, 2005 11:19 AM To: php-general@lists.php.net Subject: Re: [PHP] mysql/php date functions.. bruce wrote: thanks... but that's not it john... i'm not worried about creating the sql_statement in the php... i'm concerned that i can't seem to craft/create a basic sql cmd within mysql to get a value (other than NOW()) to work... if i do (from mysql) -- insert into foo (id, time) values (2, 33), it doesn't work... if i -- insert into foo (id, time) values (2, NOW()), it works!!... my question is why??? Without knowing the structure of your table, my guess is that the column time is expecting a valid timestamp, and 33 is not a valid MySQL timestamp. -- John C. Nichel ÜberGeek KegWorks.com 716.856.9675 [EMAIL PROTECTED] -- 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 General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] mysql/php date functions..
Hello Bruce, While the date functions are well documented - http://php.net/date - here is a little example to manipulate the date with php, rather than mysql: // set the new expiry date // DATE FUNCTIONS FOR THE EXPIRY MODULE // first perform date arithmetic $listingExpiry = mktime (0,0,0,date(m)+$monthsGoodFor,date(d)+1,date(Y)); // secondly, format the results for use in the database $expires = date (Y-m-d, $listingExpiry); // the actual update of the database with expires='$expires' ... should be below here The date format to be used in $expires depends on your database column structure. Rob. http://www.globalissa.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] date parsing
Greetings all, I am trying to find a function or a way to parse a date that has the following format 2005124 or 20051204. When I have a date that has a single digit (ie month, day) all the date/time function seem to go bizarre. When it is a full 8 digit string everything is fine. When there are delimiters between year month day (ie 2005-4-23) everything is fine. I tried strtotime(%Y/%m/%d, 2005124) and this is the result: 1970/01/23. Any thoughts? Thanks for the aid!! Phil -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] date parsing
Greetings all, I am trying to find a function or a way to parse a date that has the following format 2005124 or 20051204. When I have a date that has a single digit (ie month, day) all the date/time function seem to go bizarre. When it is a full 8 digit string everything is fine. When there are delimiters between year month day (ie 2005-4-23) everything is fine. I tried strtotime(%Y/%m/%d, 2005124) and this is the result: 1970/01/23. Any thoughts? Hi Phil, There is no programmatic way to know. in the case of your example above, 2005124, how would the program know whether it is supposed to be 2005-12-04 or 2005-1-24? JM -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] date parsing
Philippe Reynolds wrote: Greetings all, I am trying to find a function or a way to parse a date that has the following format 2005124 or 20051204. Well, the truth is, computers are stupid, and you need to explain this kind of date format to him by rewriting such date in a way that a computer can understand... From where do you get such string? Can you ask the sender to send more uniform/standard date? I tried strtotime(%Y/%m/%d, 2005124) and this is the result: 1970/01/23. Look again at the function definition http://www.php.net/strtotime The second argument is timestamp (number of seconds since the unix epoch). So if you count 2005124 seconds from January 1 1970 00:00:00 GMT you would get to January 23 1970. hope this will help you a little, N:: smime.p7s Description: S/MIME Cryptographic Signature
Re: [PHP] date parsing
Much appreciated all, I was kindda hopping that I missed something, some mysterious function... My solution to this is: if a value like 2005416 to ignore it and only look for 2005/4/16 or 20050416. Cheers Phil -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] date of file?
In addition to reading the names of the files in a directory, I also need to read the date the file was modified. Right now I've got this: if ($handle = opendir($path)) { $b=0; while (false !== ($file[$b] = readdir($handle))) { $b++; } closedir($handle); } What function do I need to use to do this? I'm working in php4. Andrew Darrow Kronos1 Productions www.pudlz.com
Re: [PHP] Date/Time Display for recurring monthly event
[EMAIL PROTECTED] wrote: Having a heck of time getting anything to work, can anyone make a suggestion to the following. I need a webpage that displays 5 recurring meeting dates, i.e. the second Wednesday, Thursday, and Friday of each month in five different locations. ?php echo Current Month: \n\n; echo date(r,strtotime(second Wednesday)).\n; echo date(r,strtotime(second Thursday)).\n; echo date(r,strtotime(second Friday)).\n\n; echo Next Month: \n\n; echo date(r,strtotime(second Wednesday,strtotime(1st October))).\n; echo date(r,strtotime(second Thursday,strtotime(1st October))).\n; echo date(r,strtotime(second Friday,strtotime(1st October))).\n\n; echo For all months of the year (for loop way) : \n\n; for($x = 1; $x =12; ++$x) { $current_month = date(F,mktime(0,0,0,$x,1,date(Y))); echo 'For the month of '.$current_month.:\n\n; echo date(r,strtotime(second Wednesday,strtotime(1st .$current_month))).\n; echo date(r,strtotime(second Thursday,strtotime(1st .$current_month))).\n; echo date(r,strtotime(second Friday,strtotime(1st .$current_month))).\n\n; } echo For all months of the year (array_map way) : \n\n; function findDates($month) { $current_month = date(F,mktime(0,0,0,$month,1,date(Y))); $x[] = date(r,strtotime(second Wednesday,strtotime(1st .$current_month))); $x[] = date(r,strtotime(second Thursday,strtotime(1st .$current_month))); $x[] = date(r,strtotime(second Friday,strtotime(1st .$current_month))); return $x; } $dates = array_map('findDates',range(1,12)); echo 'For the month of December : '.\n; print_r($dates[11]); ? Enjoy :) -- Burhan -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Date/Time Display for recurring monthly event
[EMAIL PROTECTED] wrote: Burhan, Thank you for replying, it is very much appreciated. Perhaps I did not state what I needed as well as I should have. I'm looking for the code which displays the date of the second Thursday of each month on a web page. I have to insert this code at 5 different locations on that webpage for different meetings. The scenario below describes how it needs to work. This month for example, September, the second Thursday is September 8, 2005. Up until midnight of September 8th the date on the webpage should read September 8, 2005. When midnight arrives on September 8th, the date displayed should change to October 13, 2005. If you can still help me I would be grateful. Oh, so you want to display the next available Thursday. ?php $current_month_thursday = strtotime(2nd Thursday,mktime(0,0,0,date(m)-1,0,2005)); if (strtotime(now) $current_month_thursday) { //First thursday has passed, show the first thursday //of the next month echo 'Next Meeting Date : '; $next_month = mktime(0,0,0,date(m)+1,0,date(Y)); echo date(r,strtotime(2nd Thursday,$next_month)); } else { // This month's second thursday hasn't passed yet echo date(r,$current_month_thursday); } ? This prints : [EMAIL PROTECTED] ~ $ php -q date2.php Next Meeting Date : Thu, 13 Oct 2005 00:00:00 +0300 Hope this helps, and please, reply to the list and not directly to me so others may contribute and learn. Regards, Burhan [EMAIL PROTECTED] -Original Message- From: Burhan Khalid [mailto:[EMAIL PROTECTED] Sent: Sunday, September 11, 2005 6:55 AM To: [EMAIL PROTECTED] Cc: php-general@lists.php.net Subject: Re: [PHP] Date/Time Display for recurring monthly event [EMAIL PROTECTED] wrote: Having a heck of time getting anything to work, can anyone make a suggestion to the following. I need a webpage that displays 5 recurring meeting dates, i.e. the second Wednesday, Thursday, and Friday of each month in five different locations. ?php echo Current Month: \n\n; echo date(r,strtotime(second Wednesday)).\n; echo date(r,strtotime(second Thursday)).\n; echo date(r,strtotime(second Friday)).\n\n; echo Next Month: \n\n; echo date(r,strtotime(second Wednesday,strtotime(1st October))).\n; echo date(r,strtotime(second Thursday,strtotime(1st October))).\n; echo date(r,strtotime(second Friday,strtotime(1st October))).\n\n; echo For all months of the year (for loop way) : \n\n; for($x = 1; $x =12; ++$x) { $current_month = date(F,mktime(0,0,0,$x,1,date(Y))); echo 'For the month of '.$current_month.:\n\n; echo date(r,strtotime(second Wednesday,strtotime(1st .$current_month))).\n; echo date(r,strtotime(second Thursday,strtotime(1st .$current_month))).\n; echo date(r,strtotime(second Friday,strtotime(1st .$current_month))).\n\n; } echo For all months of the year (array_map way) : \n\n; function findDates($month) { $current_month = date(F,mktime(0,0,0,$month,1,date(Y))); $x[] = date(r,strtotime(second Wednesday,strtotime(1st .$current_month))); $x[] = date(r,strtotime(second Thursday,strtotime(1st .$current_month))); $x[] = date(r,strtotime(second Friday,strtotime(1st .$current_month))); return $x; } $dates = array_map('findDates',range(1,12)); echo 'For the month of December : '.\n; print_r($dates[11]); ? Enjoy :) -- Burhan -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] date and time conversion
Hi, how to convert DD.MM.YYand HH:MM:SS into mysql date( '-MM-DD' ) and time format. I think the time is same as HH:MM:SS. Are there any php built in functions , or need to convert them using regular expressions. thanks babu - How much free photo storage do you get? Store your holiday snaps for FREE with Yahoo! Photos. Get Yahoo! Photos
Re: [PHP] date and time conversion
babu wrote: Hi, how to convert DD.MM.YYand HH:MM:SS into mysql date( '-MM-DD' ) and time format. I think the time is same as HH:MM:SS. [EMAIL PROTECTED] ~ $ php -r 'echo date(Y-m-d,strtotime(str_replace(.,/,12.12.05))).\n;' 2005-12-12 Hope that helps :) See http://php.net/date http://php.net/strtotime http://php.net/mktime For more information -- Burhan -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Date/Time Display for recurring monthly event
Having a heck of time getting anything to work, can anyone make a suggestion to the following. I need a webpage that displays 5 recurring meeting dates, i.e. the second Wednesday, Thursday, and Friday of each month in five different locations. Is there an easy (meaning code only, without using a database connection) way to get dates to display and automatically roll-over to the next months date when the actual date changes? Thanks in advance for the help. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] date field
I have a field 'updated' How can I tell if the date is older than 1 year ago (or should I think of 365 days)? `updated` date NOT NULL default '1999-12-12' I've looked at: http://ca3.php.net/manual/en/function.getdate.php Thanks, John -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] date field
John Taylor-Johnston wrote: I have a field 'updated' How can I tell if the date is older than 1 year ago (or should I think of 365 days)? `updated` date NOT NULL default '1999-12-12' From the description you gave it looks like you're using a DBMS to store the date. If it's MySQL, then just do an SQL query with a WHERE clause like this: WHERE updated DATE_SUB(NOW(), INTERVAL 1 YEAR) Jasper -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Date confusion
On Jul 28, 2005, at 9:28 AM, Linda H wrote: Hi, I must admit I am surprised at the paucity of date and time functions in PHP. I have a date stored in a MySQL database in field of datatype date. PHP doesn't seem to have a function I can use to format it for print. I tried the following but regardless of the value in the date field, it displays as 'Wednesday December 31, 1969' (I know this is the day before the UNIX epoch.). echo 'p'.date('l F j, Y',$start_date).'/p'; I tried casting the field to datetime, but it didn't pass the parser. Finally I did the following, which seems to work, but is awfully convoluted: echo 'pDate: '.date('l F j, Y',strtotime($start_date).'/p'; The other thing I'm concerned about is that strtotime takes the locale into consideration. I don't want it adjusting the date - I just want it printed out. Is there a better way to do this? SELECT DATE_FORMAT(myfield, '%W %M %e, %Y') as 'formatted_date' FROM -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Date confusion
Hi, I must admit I am surprised at the paucity of date and time functions in PHP. I have a date stored in a MySQL database in field of datatype date. PHP doesn't seem to have a function I can use to format it for print. I tried the following but regardless of the value in the date field, it displays as 'Wednesday December 31, 1969' (I know this is the day before the UNIX epoch.). echo 'p'.date('l F j, Y',$start_date).'/p'; I tried casting the field to datetime, but it didn't pass the parser. Finally I did the following, which seems to work, but is awfully convoluted: echo 'pDate: '.date('l F j, Y',strtotime($start_date).'/p'; The other thing I'm concerned about is that strtotime takes the locale into consideration. I don't want it adjusting the date - I just want it printed out. Is there a better way to do this? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Date confusion
Linda H wrote: Hi, I must admit I am surprised at the paucity of date and time functions in PHP. I have a date stored in a MySQL database in field of datatype date. PHP doesn't seem to have a function I can use to format it for print. I tried the following but regardless of the value in the date field, it displays as 'Wednesday December 31, 1969' (I know this is the day before the UNIX epoch.). echo 'p'.date('l F j, Y',$start_date).'/p'; I tried casting the field to datetime, but it didn't pass the parser. Finally I did the following, which seems to work, but is awfully convoluted: echo 'pDate: '.date('l F j, Y',strtotime($start_date).'/p'; The other thing I'm concerned about is that strtotime takes the locale into consideration. I don't want it adjusting the date - I just want it printed out. Is there a better way to do this? If you have it in MySQL, there are a bunch of native MySQL functions to format it on the select itself. See http://mysql.com/datetime Or, if you want to manipulate it using PHP's functions, get MySQL to return it to you as a UNIX timestamp. -Rasmus -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Date confusion
hi Linda I must admit I am surprised at the paucity of date and time functions in PHP. You may want to check out the PEAR Date class: http://pear.php.net/package/Date Rob -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Date Handling Recommendations
Hi all, I need to manage some records with dates. mmdd I'm putting select options breaking the three up in numeric pull downs. no problem gathering and storing the data in my mysql db as integers then posting them for existing records etc. i know their is a datetime datatype but it doesnt seem easier to use this data type than using integers...any tips or routines for handling this? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Date Handling Recommendations
Hi all, I need to manage some records with dates. mmdd I'm putting select options breaking the three up in numeric pull downs. no problem gathering and storing the data in my mysql db as integers then posting them for existing records etc. i know their is a datetime datatype but it doesnt seem easier to use this data type than using integers...any tips or routines for handling this? It is much much easier to use at least the DATE type in your database. What if, six months from now you want to select all records that occured on even numbered Tuesdays? How would you do that if all you have is integers? I suppose you could look at every single row and do the math in PHP, but that's going to be a pain and won't scale very well... Good luck! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Date Handling Recommendations
Hi all, I need to manage some records with dates. mmdd I'm putting select options breaking the three up in numeric pull downs. no problem gathering and storing the data in my mysql db as integers then posting them for existing records etc. i know their is a datetime datatype but it doesnt seem easier to use this data type than using integers...any tips or routines for handling this? I guess this is my day to be dense, but I don't really understand the question. One part I think I understand is that you don't see the benefit to using the DATE datatype to store your dates. The DATE datatype allows you to do many things with dates that would be difficult storing them as integers. For instance, what would you have to do to get the day of the week for a day 66 days prior to the stored date? If your date was stored in a DATE field, all you would have to do is: $result=mysql_query(SELECT DATE_FORMAT(DATE_SUB(`stored_date`, interval 66 days) ,%W) from tablename where...); $row=mysql_fetch_row($result); echo The day if the week is .$row[0]; ...if your dates are stored in integer fields, how would you easily come about a similar result? JM -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Date Handling Recommendations
Jim Moseby wrote: Hi all, I need to manage some records with dates. mmdd I'm putting select options breaking the three up in numeric pull [snip] For instance, what would you have to do to get the day of the week for a day 66 days prior to the stored date? If your date was stored in a DATE field, all you would have to do is: $result=mysql_query(SELECT DATE_FORMAT(DATE_SUB(`stored_date`, interval 66 days) ,%W) from tablename where...); $row=mysql_fetch_row($result); echo The day if the week is .$row[0]; ...if your dates are stored in integer fields, how would you easily come about a similar result? JM Um... Just because... $dayOfTheWeek = date(l, $dateFromDatabase - (66 * 86400)); *assuming by integer fields the OP is talking about unix timestamps* But you, and a previous poster, do bring up an interesting idea about this. I'd never thought about just how many different things you can do, or might need to do, with a DATE field in the database. Thanks! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Date Handling Recommendations
thanks all. i just made the changes and its working smooth. i remember having a bunch of drama trying to use DATE data type...oh well, i just needed something to get me off my butt haha thanks again On 7/21/05, Philip Hallstrom [EMAIL PROTECTED] wrote: Hi all, I need to manage some records with dates. mmdd I'm putting select options breaking the three up in numeric pull downs. no problem gathering and storing the data in my mysql db as integers then posting them for existing records etc. i know their is a datetime datatype but it doesnt seem easier to use this data type than using integers...any tips or routines for handling this? It is much much easier to use at least the DATE type in your database. What if, six months from now you want to select all records that occured on even numbered Tuesdays? How would you do that if all you have is integers? I suppose you could look at every single row and do the math in PHP, but that's going to be a pain and won't scale very well... Good luck! -- John Martinez http://www.funkyfreshdesigns.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Date function and MySQL
this seems pretty interesting, i'm tring to write a code in php to get those two outputs, but bit confused in counting weeks. could somebody clear me.. what is the first *date* of the first week of year 2005? is it saturday jan 1st 2005 (assuming first week starts from jan 1 of any year) or is it sunday jan 3rd 2005 (assuming first day of a week is monday) or anything else. thanks vk. On 7/19/05, Arno Coetzee [EMAIL PROTECTED] wrote: Philip Thompson wrote: Hi all. I have the week number (for example, this is the 29th week of the year and it begins on 7/17/05). Does anyone know how to obtain the first (and maybe the last) date of the week if you only know the week number of the year? Would it be better for me to obtain this in PHP or MySQL? or both? I have researched the archives on a few lists and I know that others have asked this same questions, but I have not found a good solution. I have also looked on MySQL's date and time functions page, but had little luck. Any thoughts would be appreciated. ~Philip Hi Philip give this a go... i played around with the date functions of mysql select date_sub(curdate() , interval (date_format(curdate() , '%w')-1) day) as firstday , date_add(curdate() , interval (7 - date_format(curdate() , '%w')) day) as lastday it will give you the date of the monday and the sunday of the current week hope this solves your problem. Arno -- 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] Date function and MySQL
Hi all. I have the week number (for example, this is the 29th week of the year and it begins on 7/17/05). Does anyone know how to obtain the first (and maybe the last) date of the week if you only know the week number of the year? Would it be better for me to obtain this in PHP or MySQL? or both? i did a little coding, try this and give me any comments.. ?php $week = 7; $year = 2028; $uts = mktime(0,0,0,1,1,$year); // 604800 = 7 days in seconds $w2s = (($week-1) * 604800); //unix time stamp for the first date of the given week $suts = $uts + $w2s; echo pre; echo Start Date: . date(j-M-Y (l),($suts)); echo br; //518000 = 6 days in seconds echo Last Date: . date(j-M-Y (l),($suts+518400)); echo pre; ? happy coding vk. I have researched the archives on a few lists and I know that others have asked this same questions, but I have not found a good solution. I have also looked on MySQL's date and time functions page, but had little luck. Any thoughts would be appreciated. ~Philip Hi Philip give this a go... i played around with the date functions of mysql select date_sub(curdate() , interval (date_format(curdate() , '%w')-1) day) as firstday , date_add(curdate() , interval (7 - date_format(curdate() , '%w')) day) as lastday it will give you the date of the monday and the sunday of the current week hope this solves your problem. Arno -- 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] Date function and MySQL
Philip Thompson wrote: Hi all. I have the week number (for example, this is the 29th week of the year and it begins on 7/17/05). Does anyone know how to obtain the first (and maybe the last) date of the week if you only know the week number of the year? Would it be better for me to obtain this in PHP or MySQL? or both? I have researched the archives on a few lists and I know that others have asked this same questions, but I have not found a good solution. I have also looked on MySQL's date and time functions page, but had little luck. Any thoughts would be appreciated. ~Philip Hi Philip give this a go... i played around with the date functions of mysql select date_sub(curdate() , interval (date_format(curdate() , '%w')-1) day) as firstday , date_add(curdate() , interval (7 - date_format(curdate() , '%w')) day) as lastday it will give you the date of the monday and the sunday of the current week hope this solves your problem. Arno -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Date function and MySQL
Hi all. I have the week number (for example, this is the 29th week of the year and it begins on 7/17/05). Does anyone know how to obtain the first (and maybe the last) date of the week if you only know the week number of the year? Would it be better for me to obtain this in PHP or MySQL? or both? I have researched the archives on a few lists and I know that others have asked this same questions, but I have not found a good solution. I have also looked on MySQL's date and time functions page, but had little luck. Any thoughts would be appreciated. ~Philip -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] date() problem
Philip Hallstrom wrote: of leap years between the two dates. Leap years occur every 4 years, and 17 / 4 = 4.25, so there were 4 leap years between 7/6/88 and 7/6/05 and Just to nitpick... :-) http://en.wikipedia.org/wiki/Leap_year The Gregorian calendar adds an extra day to February, making it 29 days long, in years where the quotient has no remainder when divided by 4, excluding years where the quotient has no remainder when divided by 100, but including years where the quotient has no remainder when divided by 400. So 1996, 2000, and 2400 are leap years but 1800, 1899, 1900 and 2100 are not. Touche! One more reason not to use the OP's method but rather the one posted by Richard Lynch. kgt -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] date() problem
Hey Richard, Thanks, you've pulled my butt outa the fire again :-) Cheers, Ryan On 7/6/2005 10:59:36 PM, Richard Lynch ([EMAIL PROTECTED]) wrote: On Wed, July 6, 2005 12:07 pm, Ryan A said: I'm confused, this should give me the age as 17 instead of 16...but it does not...any ideas why? ?php print date(Y:m:d); $age=1988-07-06; $day1=strtotime($age); $day2 = strtotime(date(Y-m-d)); $dif_s = ($day2-$day1); $dif_d = ($dif_s/60/60/24); $age = floor(($dif_d/365.24)); echo $age; ? 365.24 is an appoximation. Sooner or later, it's gonna bit you in the butt. If you want somebody's age accurately, you're probably going to have to do it the hard way. Something like this might work: ?php $DOB = 1988-07-06; $now = date('Y-m-d'); list($by, $bm, $bd) = explode('-', $DOB); list($ny, $nm, $nd) = explode('-', $now); $age = $ny - $by; if ($age){ if ($bm $nm){ // do nothing, they were born before this month // so subtracting the years is correct } elseif ($nm $bm){ $age--; //They were born in a later month, so not quite a year yet } else{ //They were born this month. Count the days. if ($bd $nd){ //Do nothing. They were born before this date. } elseif ($nd $bd){ $age--; //They were born later this month, so not quite a year yet } else{ //It's their birthday! Go ahead and count it as a year, //unless you want to futz with the hour of their birth... } } } if (!$age){ //Do whatever you want with children less than 1 year old... //return it as X months or just call it infant or pretend they're 1 //or whatever. //Maybe even just use $age (which is 0) and call it done. } ? -- Like Music? http://l-i-e.com/artists.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] date() problem
Hi, I'm confused, this should give me the age as 17 instead of 16...but it does not...any ideas why? ?php print date(Y:m:d); $age=1988-07-06; $day1=strtotime($age); $day2 = strtotime(date(Y-m-d)); $dif_s = ($day2-$day1); $dif_d = ($dif_s/60/60/24); $age = floor(($dif_d/365.24)); echo $age; ? Thanks, Ryan -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] date() problem
On Jul 6, 2005, at 2:07 PM, Ryan A wrote: Hi, I'm confused, this should give me the age as 17 instead of 16...but it does not...any ideas why? ?php print date(Y:m:d); $age=1988-07-06; $day1=strtotime($age); $day2 = strtotime(date(Y-m-d)); $dif_s = ($day2-$day1); $dif_d = ($dif_s/60/60/24); $age = floor(($dif_d/365.24)); echo $age; ? Thanks, Ryan -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php If I change $day2 to =time(); instead of strtotime() I get 17. Could be some weirdness going on with using date()?. Edward Vermillion [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] date() problem
On Jul 6, 2005, at 2:35 PM, Edward Vermillion wrote: On Jul 6, 2005, at 2:07 PM, Ryan A wrote: Hi, I'm confused, this should give me the age as 17 instead of 16...but it does not...any ideas why? ?php print date(Y:m:d); $age=1988-07-06; $day1=strtotime($age); $day2 = strtotime(date(Y-m-d)); $dif_s = ($day2-$day1); $dif_d = ($dif_s/60/60/24); $age = floor(($dif_d/365.24)); echo $age; ? Thanks, Ryan -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php If I change $day2 to =time(); instead of strtotime() I get 17. Could be some weirdness going on with using date()?. Actually it's in the math... With the numbers you have here $dif_d would need to be 6209.24/25 to get up to 17, so the fault lies in the 365.24/25 assumption for a day. Don't ask me how to get around it... it makes my head hurt. :D Edward Vermillion [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] date() problem
On Wed, July 6, 2005 12:07 pm, Ryan A said: I'm confused, this should give me the age as 17 instead of 16...but it does not...any ideas why? ?php print date(Y:m:d); $age=1988-07-06; $day1=strtotime($age); $day2 = strtotime(date(Y-m-d)); $dif_s = ($day2-$day1); $dif_d = ($dif_s/60/60/24); $age = floor(($dif_d/365.24)); echo $age; ? 365.24 is an appoximation. Sooner or later, it's gonna bit you in the butt. If you want somebody's age accurately, you're probably going to have to do it the hard way. Something like this might work: ?php $DOB = 1988-07-06; $now = date('Y-m-d'); list($by, $bm, $bd) = explode('-', $DOB); list($ny, $nm, $nd) = explode('-', $now); $age = $ny - $by; if ($age){ if ($bm $nm){ // do nothing, they were born before this month // so subtracting the years is correct } elseif ($nm $bm){ $age--; //They were born in a later month, so not quite a year yet } else{ //They were born this month. Count the days. if ($bd $nd){ //Do nothing. They were born before this date. } elseif ($nd $bd){ $age--; //They were born later this month, so not quite a year yet } else{ //It's their birthday! Go ahead and count it as a year, //unless you want to futz with the hour of their birth... } } } if (!$age){ //Do whatever you want with children less than 1 year old... //return it as X months or just call it infant or pretend they're 1 //or whatever. //Maybe even just use $age (which is 0) and call it done. } ? -- Like Music? http://l-i-e.com/artists.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] date() problem
Ryan A wrote: Hi, I'm confused, this should give me the age as 17 instead of 16...but it does not...any ideas why? ?php print date(Y:m:d); $age=1988-07-06; $day1=strtotime($age); $day2 = strtotime(date(Y-m-d)); $dif_s = ($day2-$day1); $dif_d = ($dif_s/60/60/24); $age = floor(($dif_d/365.24)); echo $age; ? Thanks, Ryan Subtracting the timestamps gives you 536457600 seconds, which is correct, but ( $dif_s / 60 / 60 / 24 ) gives you the actual number of days between these two dates. We say on *average* there are 365.25 days in a year, so 17 years (the correct age in years between these two dates) has about 17 * 365.25 = 6209.25 days. In actuality, there are 6209 days between these two dates. This seems close, but note that 6209.25 / 365.25 = 17 but 6209 / 365.25 = 16.9993155 And of course floor on 16.9993155 is still just 16. I don't think you can accurately calculate dates in this way without calculating the actual number of leap years between the two dates. Leap years occur every 4 years, and 17 / 4 = 4.25, so there were 4 leap years between 7/6/88 and 7/6/05 and therefore 365 * 17 + 4 = 6209 days, the actual number of days between these two dates. But note that ( 6209 - 4 ) / 365 = 17, which is correct. If you subtract the number of extra days due to leap years, then there are precisely 365 days in each year. It boils down to the fact that though there are on *average* 365.25 days in a calendar year, there are never *actually* 365.25 days in a calendar year. There are only either 365 or 366. kgt -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] date() problem
On Jul 6, 2005, at 3:59 PM, Richard Lynch wrote: 365.24 is an appoximation. Sooner or later, it's gonna bit you in the butt. If you want somebody's age accurately, you're probably going to have to do it the hard way. Something like this might work: ?php $DOB = 1988-07-06; $now = date('Y-m-d'); list($by, $bm, $bd) = explode('-', $DOB); list($ny, $nm, $nd) = explode('-', $now); $age = $ny - $by; if ($age){ if ($bm $nm){ // do nothing, they were born before this month // so subtracting the years is correct } elseif ($nm $bm){ $age--; //They were born in a later month, so not quite a year yet } else{ //They were born this month. Count the days. if ($bd $nd){ //Do nothing. They were born before this date. } elseif ($nd $bd){ $age--; //They were born later this month, so not quite a year yet } else{ //It's their birthday! Go ahead and count it as a year, //unless you want to futz with the hour of their birth... } } } if (!$age){ //Do whatever you want with children less than 1 year old... //return it as X months or just call it infant or pretend they're 1 //or whatever. //Maybe even just use $age (which is 0) and call it done. } ? Actually, I was thinking it could be done inside a simple formula since his original formula works on the leap years, ie. years divisible by four. I guess the trick would be figuring out the actual seconds in a year and doing most of the calculations on the unix timestamp. Something is tickling the back of my brain on this but I can't see it just yet. Eh... Edward Vermillion [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] date() problem
of leap years between the two dates. Leap years occur every 4 years, and 17 / 4 = 4.25, so there were 4 leap years between 7/6/88 and 7/6/05 and Just to nitpick... :-) http://en.wikipedia.org/wiki/Leap_year The Gregorian calendar adds an extra day to February, making it 29 days long, in years where the quotient has no remainder when divided by 4, excluding years where the quotient has no remainder when divided by 100, but including years where the quotient has no remainder when divided by 400. So 1996, 2000, and 2400 are leap years but 1800, 1899, 1900 and 2100 are not. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] date() problem
On Jul 6, 2005, at 4:44 PM, Philip Hallstrom wrote: of leap years between the two dates. Leap years occur every 4 years, and 17 / 4 = 4.25, so there were 4 leap years between 7/6/88 and 7/6/05 and Just to nitpick... :-) http://en.wikipedia.org/wiki/Leap_year The Gregorian calendar adds an extra day to February, making it 29 days long, in years where the quotient has no remainder when divided by 4, excluding years where the quotient has no remainder when divided by 100, but including years where the quotient has no remainder when divided by 400. So 1996, 2000, and 2400 are leap years but 1800, 1899, 1900 and 2100 are not. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php I always wondered what kind of drugs those guys were on when they came up with the leap-year system... :P One interesting side note to the op's problem, since I'm not going to be able to do anything else till I figure this out now..., if one of the dates is a leap year the 365.25 works fine, which make me wonder how the strtotime() function is working... or maybe that's what it's supposed to do... ;) Edward Vermillion [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] date() problem
On Jul 6, 2005, at 5:17 PM, Edward Vermillion wrote: On Jul 6, 2005, at 4:44 PM, Philip Hallstrom wrote: of leap years between the two dates. Leap years occur every 4 years, and 17 / 4 = 4.25, so there were 4 leap years between 7/6/88 and 7/6/05 and Just to nitpick... :-) http://en.wikipedia.org/wiki/Leap_year The Gregorian calendar adds an extra day to February, making it 29 days long, in years where the quotient has no remainder when divided by 4, excluding years where the quotient has no remainder when divided by 100, but including years where the quotient has no remainder when divided by 400. So 1996, 2000, and 2400 are leap years but 1800, 1899, 1900 and 2100 are not. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php I always wondered what kind of drugs those guys were on when they came up with the leap-year system... :P One interesting side note to the op's problem, since I'm not going to be able to do anything else till I figure this out now..., if one of the dates is a leap year the 365.25 works fine, which make me wonder how the strtotime() function is working... or maybe that's what it's supposed to do... ;) But then, even if I do figure this out, it's still going to tell me I'm only 35... which is a bit off... As usual Richard's way is probably the best for any real world age deduction. ;) Edward Vermillion [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] date() problem
On Jul 6, 2005, at 5:31 PM, Edward Vermillion wrote: On Jul 6, 2005, at 5:17 PM, Edward Vermillion wrote: On Jul 6, 2005, at 4:44 PM, Philip Hallstrom wrote: of leap years between the two dates. Leap years occur every 4 years, and 17 / 4 = 4.25, so there were 4 leap years between 7/6/88 and 7/6/05 and Just to nitpick... :-) http://en.wikipedia.org/wiki/Leap_year The Gregorian calendar adds an extra day to February, making it 29 days long, in years where the quotient has no remainder when divided by 4, excluding years where the quotient has no remainder when divided by 100, but including years where the quotient has no remainder when divided by 400. So 1996, 2000, and 2400 are leap years but 1800, 1899, 1900 and 2100 are not. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php I always wondered what kind of drugs those guys were on when they came up with the leap-year system... :P One interesting side note to the op's problem, since I'm not going to be able to do anything else till I figure this out now..., if one of the dates is a leap year the 365.25 works fine, which make me wonder how the strtotime() function is working... or maybe that's what it's supposed to do... ;) But then, even if I do figure this out, it's still going to tell me I'm only 35... which is a bit off... As usual Richard's way is probably the best for any real world age deduction. ;) Well, I'll let you test through it but it seems to work with the two or three dates I ran through... ?php $bd=1988-07-07; // birth date $td=2005-07-06; // today $day1 = strtotime($bd); $day2 = strtotime($td); $sy = 31536000; // short year 365 days $spd = 86400; // seconds per day $realAge = floor(($day2-$day1-($spd*floor((($day2 - $day1)/$sy)/4)))/$sy); print $realAge; exit; ? I left $sy and $spd in so you could see where those values were coming from but you could just as well stick the numbers in for the vars and only have $day1 and $day2 hanging around. of course it only works on most systems with birth dates before the epoch... :P Edward Vermillion [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] date problem
Hi all I have a database that holds car rental info DB: carrental_from (datetime field) carrental_to (datetime field) carrental_price (datetime field) [rates are per hour] The values I have are like: -00-00 00:00:00,-00-00 07:00:00,10 (all year around 00:00-07:00) -00-00 07:00:00,-00-00 00:00:00,20 (all year around 07:00-00:00) 2005-12-22 07:00:00,2006-01-02 00:00:00,15 (christmas period 00:00-07:00) 2005-12-22 00:00:00,2006-01-02 07:00:00,25 (christmas period 07:00-00:00) The user selects dates ($from - $to) to rent a car and he gets the price accordingly. I can do a (($to-$from)/60/60) and get the total number of hours but depending on the date and time you get a different result. Can anyone help with the SQL? Thanks in advance Mario -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] $date(l-m);
John Taylor-Johnston wrote: $mydata-lastinsalled = 2004-05; take a good look at mktime(); How can I determne if $mydata-lastinsalled is one year or more older than the current $date(l-m); Anyting simple and over looked? I have been browsing the manual:: http://ca.php.net/manual/en/function.strtotime.php http://ca.php.net/manual/en/function.date.php John -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] $date(l-m);
$mydata-lastinsalled = 2004-05; How can I determne if $mydata-lastinsalled is one year or more older than the current $date(l-m); Anyting simple and over looked? I have been browsing the manual:: http://ca.php.net/manual/en/function.strtotime.php http://ca.php.net/manual/en/function.date.php John -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] $date(l-m);
is it possible for $mydata-lastinsalled to have -MM-DD format? ie: 2004-05-31 you can use strtotime to convert it to unix timestamp to compare...something like this: $stamp = strtotime('2004-06-31'); // $mydata-lastinsalled if($stamp = strtotime('1 year ago')) { echo 'less than 1 year'; } else { echo 'over 1 year'; } otherwise its impossible to tell if it is over one year without knowing the day as well.. unless you guess and figure on the first of the month.. John Taylor-Johnston wrote: $mydata-lastinsalled = 2004-05; How can I determne if $mydata-lastinsalled is one year or more older than the current $date(l-m); Anyting simple and over looked? I have been browsing the manual:: http://ca.php.net/manual/en/function.strtotime.php http://ca.php.net/manual/en/function.date.php John -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Date class
Everyone, Do you know of any decent Date/Time handling classes? We require the following functionality 1. Date's prior to 1970 handled (not reliant on the PHP date) 2. add/subtract days to/from a date 3. subtract two dates returning number of days Any pointers are welcome. Thanks for your time in advance. Devraj -- Devraj Mukherjee ([EMAIL PROTECTED]) Eternity Technologies Pty. Ltd. ACN 107 600 975 P O Box 5949 Wagga Wagga NSW 2650 Australia Voice: +61-2-69717131 / Fax: +61-2-69251039 http://www.eternitytechnologies.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Date class
Devraj Mukherjee wrote: Everyone, Do you know of any decent Date/Time handling classes? We require the following functionality 1. Date's prior to 1970 handled (not reliant on the PHP date) 2. add/subtract days to/from a date 3. subtract two dates returning number of days Any pointers are welcome. Thanks for your time in advance. Devraj Have you looked at the PEAR Date class? http://pear.php.net/package/Date /Mattias -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Date class
Matthias wrote: Have you looked at the PEAR Date class? http://pear.php.net/package/Date PEAR Date is good - I use it a lot - but watch out for this bug if you're running on Windows http://pear.php.net/bugs/bug.php?id=2344 basically, there's some getenv/putenv trickery in the Date_Timezone::inDaylightTime method called in Date::before Date::after which causes access violations. Unfortunately the Date owner's attitude is roughly 'not my problem, windows sucks' (which may be true but doesn't help much :-/ ) R -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Date time simplicity gotten out of hand
Hey, I thought this would be simple and just a few mins of programming but along the way...i have managed to confuse myself ;-D I have 2 field in my table users_online: present_date_time datetime expires_in datetime for present_date_time I am using now() to insert but for expires_in I need to have it now()+5 mins I was screwing around with now()+ X but thats getting me some weird results if its the end of the hour or day... Please help. Thanks, Ryan -- No virus found in this outgoing message. Checked by AVG Anti-Virus. Version: 7.0.308 / Virus Database: 266.9.5 - Release Date: 4/7/2005 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Date time simplicity gotten out of hand
On Apr 9, 2005 12:35 PM, Ryan A [EMAIL PROTECTED] wrote: Hey, I thought this would be simple and just a few mins of programming but along the way...i have managed to confuse myself ;-D I have 2 field in my table users_online: present_date_time datetime expires_in datetime for present_date_time I am using now() to insert but for expires_in I need to have it now()+5 mins I was screwing around with now()+ X but thats getting me some weird results if its the end of the hour or day... mysql select NOW(), DATE_ADD( NOW(), INTERVAL 5 MINUTE ); +-+--+ | NOW() | DATE_ADD( NOW(), INTERVAL 5 MINUTE ) | +-+--+ | 2005-04-09 12:27:36 | 2005-04-09 12:32:36 | +-+--+ 1 row in set (0.00 sec) -- Greg Donald Zend Certified Engineer http://destiney.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Date time simplicity gotten out of hand
On 4/9/2005 7:28:34 PM, Greg Donald ([EMAIL PROTECTED]) wrote: On Apr 9, 2005 12:35 PM, Ryan A [EMAIL PROTECTED] wrote: Hey, I thought this would be simple and just a few mins of programming but along the way...i have managed to confuse myself ;-D I have 2 field in my table users_online: present_date_time datetime expires_in datetime for present_date_time I am using now() to insert but for expires_in I need to have it now()+5 mins I was screwing around with now()+ X but thats getting me some weird results if its the end of the hour or day... mysql select NOW(), DATE_ADD( NOW(), INTERVAL 5 MINUTE ); +-+--+ | NOW() | DATE_ADD( NOW(), INTERVAL 5 MINUTE ) | +-+--+ | 2005-04-09 12:27:36 | 2005-04-09 12:32:36 | +-+--+ 1 row in set (0.00 sec) F**K! If every you see me on the roadjust give a kick. WTF was I thinkingI went all around the monkeys butt trying to do this in another way instead of simple SQL. Thanks dude, Ryan -- No virus found in this outgoing message. Checked by AVG Anti-Virus. Version: 7.0.308 / Virus Database: 266.9.5 - Release Date: 4/7/2005 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] date() function help
I am writing an application to allow users to enter weekly data and am storing the data based on the year and the ISO week number. The data will be reported on a monthly basis and therefore I need a way to find the ISO week number for the first full week of the month (Monday-Sunday) and the ISO week number for the last week (starting on the last Sunday of the month). Does anyone have a suggestion? Thanks! -- John Eggen [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] date of the end of support (security updates)
Hi i am searching the date of the end of support for the different versions of php where can i find them? thx -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] date of the end of support (security updates)
[EMAIL PROTECTED] wrote: Hi i am searching the date of the end of support for the different versions of php there is no support as such. php4 is pretty much bugfix only. all the new work is being focused on php5. php3? (cue trumpets, cue 70's yellow, scrolling text, 'once a upon a time, long long ago'**) the people who develop php itself do so voluntarily, you can't hold them to anything. (almost) everything there is to know about the state of php can be found on php.net, and if you need commercial support then zend.com might be a place to start looking -- no affliation, never spent a dime on zend software, but there is no question that they know php ;-). if you really want to know what's up with development subscribe to the cvs mailinglist. **no I'm not a starwars freak, it's just that they showed starwars on telly at christmas, about 7 years in a row, when I was growing up - it kinda suck in my head :-). where can i find them? thx -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Date() reporting wrong on OS X server intermittently
Hi There, I have an app which is installed across a dozen odd organisations, and one this week which is running on an OS X Xserve machine. Intermittently this week the PHP app has been seeing the wrong time. Shifting 12hrs at a time. The IT administrator who runs the box says that it's all okay, and it's synced correctly with a master server. Suspiciously enough some workmen had been in on the weekeend prior and may have cut/spiked the power to the box... (coincidence?) Is it possible that PHP could see a different date to the OSX GUI ? I wouldn't think it would be possible at all. Has anyone out there seen weird problems like this before ? Many Thanks, Rowan -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Date() reporting wrong on OS X server intermittently
The 12 hours seems suspicious to me since it's the difference between AM and PM. My other guess would be that it's grabbing Greenwich time, but it doesn't look like your offset from GMT is twelve hours. On Feb 17, 2005, at 4:12 PM, Rowan Hick wrote: Hi There, I have an app which is installed across a dozen odd organisations, and one this week which is running on an OS X Xserve machine. Intermittently this week the PHP app has been seeing the wrong time. Shifting 12hrs at a time. The IT administrator who runs the box says that it's all okay, and it's synced correctly with a master server. Suspiciously enough some workmen had been in on the weekeend prior and may have cut/spiked the power to the box... (coincidence?) Is it possible that PHP could see a different date to the OSX GUI ? I wouldn't think it would be possible at all. Has anyone out there seen weird problems like this before ? Many Thanks, Rowan -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- Brent Baisley Systems Architect Landover Associates, Inc. Search Advisory Services for Advanced Technology Environments p: 212.759.6400/800.759.0577 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Date() reporting wrong on OS X server intermittently
It could be flicking between GMT and local time, local time is 13 hrs difference. There's nothing on the server that would be changing an environment variable for the PHP app, so I'm pretty much ruling out interference from that. I still keep coming back to the server clock must be wrong but the IT guy assures me it isn't. Has anyone seen an error in PHP when it's gotten the date wrong. I can't imagine this ever happening. (FYI OSX Server 10.3 PHP 4.3.6 ) On 18/2/05 9:00 AM, Brent Baisley [EMAIL PROTECTED] wrote: The 12 hours seems suspicious to me since it's the difference between AM and PM. My other guess would be that it's grabbing Greenwich time, but it doesn't look like your offset from GMT is twelve hours. On Feb 17, 2005, at 4:12 PM, Rowan Hick wrote: Hi There, I have an app which is installed across a dozen odd organisations, and one this week which is running on an OS X Xserve machine. Intermittently this week the PHP app has been seeing the wrong time. Shifting 12hrs at a time. The IT administrator who runs the box says that -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Date Update
Everybody sent a return receipt, right? ;) -- John C. Nichel ÜberGeek KegWorks.com 716.856.9675 [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] [suspicious - maybe spam] Re: [PHP] Date Update
Adi Pramadi wrote: I'm new in PHP programing, and i need a way to add date in php. here is the sample If today is 29/01/2005 (dd/mm/yy) and i need to make an apointment for another 10 days the date recorded sould be 08/02/2005 and not 39/01/2005 is there a way to do it in just like in asp (add date) ? http://php.net/mktime -- Like Music? http://l-i-e.com/artists.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Date Update
Dear Friends, I'm new in PHP programing, and i need a way to add date in php. here is the sample If today is 29/01/2005 (dd/mm/yy) and i need to make an apointment for another 10 days the date recorded sould be 08/02/2005 and not 39/01/2005 is there a way to do it in just like in asp (add date) ? Regards, Adi -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Date ranges
Hi NG, I have a page that is for booking attendance to events, and instead of using a date picker, I want to display drop-down selects which cover the ranges of dates that the event is occurring at. My question is, is there an easy way to determine the dates in between the date from and to that is stored in the database? I know how to easily determine the number of days I know that if I spent time on it, I would be able to do it, but I have a very close deadline and if anyone else has been through this I would *really* appreciate the help... Mikey -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php