Re: [PHP] Dates and Mysql
VamVan wrote: Hello Gang, I have a Mysql table which has timestamp for the date the record was created. I was wondering how is it possible for me to query the table to retrieve all the records that are one week less than the time stamp? Thanks, V I'm assuming you meant get records one week less than the current system timestamp. date('Y-m-d G:i:s', strtotime('1 week ago')); Thank you, Micah Gersten onShore Networks Internal Developer http://www.onshore.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Dates and Mysql
VamVan wrote: Hello Gang, I have a Mysql table which has timestamp for the date the record was created. I was wondering how is it possible for me to query the table to retrieve all the records that are one week less than the time stamp? http://dev.mysql.com/doc/refman/5.0/en/date-and-time-functions.html -- Postgresql php tutorials http://www.designmagick.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Dates and Mysql
This one time, at band camp, VamVan [EMAIL PROTECTED] wrote: I was wondering how is it possible for me to query the table to retrieve all the records that are one week less than the time stamp? SELECT DATE_SUB(date_time_column, INTERVAL 1 WEEK) FROM your_table; http://www.phpro.org/tutorials/Introduction-to-PHP-and-MySQL.html#45 Kevin -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Dates Again
VamVan írta: Hello All, I have a date in 2008-03-29 12:15:00 format. - How can I reduce one day from it? - How can I reduce one hour from it? - How can I add 1 hour to today's date? Thanks just convert it to a timestamp with strtotime() then you can manipulate it by adding/substracting - 86400 for a day - 3600 for an hour then convert back with strftime() http://hu.php.net/strtotime http://hu.php.net/strftime greets, Zoltán Németh -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Dates Again
Zoltán Németh wrote: VamVan írta: Hello All, I have a date in 2008-03-29 12:15:00 format. - How can I reduce one day from it? - How can I reduce one hour from it? - How can I add 1 hour to today's date? Thanks just convert it to a timestamp with strtotime() then you can manipulate it by adding/substracting - 86400 for a day - 3600 for an hour then convert back with strftime() http://hu.php.net/strtotime http://hu.php.net/strftime greets, Zoltán Németh I believe you can also use strtoime() http://us.php.net/manual/en/function.strtotime.php $time = strtotime($inputTime); $time = strtotime('-1 day', $time); $outputTime = strftime('%Y-%m%d', $time); I'm not sure which is more efficient, but it helps when you're looking for next thursday or other things like that. -- Ray Hauge www.primateapplications.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Dates Again
On Monday 31 March 2008, Zoltán Németh wrote: VamVan írta: Hello All, I have a date in 2008-03-29 12:15:00 format. - How can I reduce one day from it? - How can I reduce one hour from it? - How can I add 1 hour to today's date? Thanks just convert it to a timestamp with strtotime() then you can manipulate it by adding/substracting - 86400 for a day - 3600 for an hour then convert back with strftime() http://hu.php.net/strtotime http://hu.php.net/strftime greets, Zoltán Németh Do not use ints for date/time math. There are WY too many wacky edge cases that can bite you in the butt. http://www.php.net/manual/en/function.date-create.php Use a DateTime object. You can do all sorts of manipulations to it and it will handle all the timezone, daylight savings, leap year, and similar weirdness for you. It also supports 64-bit dates internally so you can cover the entire span of human history and then some. -- Larry Garfield AIM: LOLG42 [EMAIL PROTECTED] ICQ: 6817012 If nature has made any one thing less susceptible than all others of exclusive property, it is the action of the thinking power called an idea, which an individual may exclusively possess as long as he keeps it to himself; but the moment it is divulged, it forces itself into the possession of every one, and the receiver cannot dispossess himself of it. -- Thomas Jefferson -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Dates and different time zones
[snip] So a wonder who to handle different time zones? Have any of your experience of this? [/snip] The server lives in one time zone and therefore cannot handle multiples unless there is some new widget available for this. There are a couple of methods available; 1. Use JavaScript to capture 'local' (client-side) time to a PHP variable. 2. Use time zone offsets for ranges of IP addresses known to be in each time zone. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Dates and different time zones
Niklas Karlsson wrote: I am creating an international site that is going to get used in both American and Europe. And I wonder how to handle the different time zones, because I want the date and time to be correct after the place your using the application. I now have the date_default_timezone_set() to Europe/Stockholm, and all dates that is saved into the database is timestamp with time zone (using PostgreSQL). So a wonder who to handle different time zones? Have any of your experience of this? Store all of your dates as GMT. Perform all date based calculations around GMT also, and then offset the values for localised display only. This way you only need to store the GMT offsets for each user, i.e. GMT+1 or GMT-8 when it comes to displaying the dates to them. The trick is to use a constant base date for all data, and only being the user timezones into play when needed. Cheers, Rich -- Zend Certified Engineer http://www.corephp.co.uk Never trust a computer you can't throw out of a window -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Dates and different time zones
- Original Message - From: Richard Davey [EMAIL PROTECTED] To: php-general@lists.php.net Sent: Tuesday, April 10, 2007 3:43 PM Subject: Re: [PHP] Dates and different time zones Niklas Karlsson wrote: I am creating an international site that is going to get used in both American and Europe. And I wonder how to handle the different time zones, because I want the date and time to be correct after the place your using the application. I now have the date_default_timezone_set() to Europe/Stockholm, and all dates that is saved into the database is timestamp with time zone (using PostgreSQL). So a wonder who to handle different time zones? Have any of your experience of this? Store all of your dates as GMT. Perform all date based calculations around GMT also, and then offset the values for localised display only. This way you only need to store the GMT offsets for each user, i.e. GMT+1 or GMT-8 when it comes to displaying the dates to them. The trick is to use a constant base date for all data, and only being the user timezones into play when needed. Actually, I find that it is better not to bother storing anything for the user at all. At the first chance, get some JavaScript to read the local time of the client machine and send it back to the server, either with the login data, using some AJAX or along with any link the user might click on the welcome screen, for example, the language choice. Then use the offset from his local time to the server time for every time information, substract it from any time information you read from them, add it to anything you send them. This works whether the user is registered or not, whether he/she travels or remains in the same time zone and spares you the trouble of keeping your IP to country to timezone table updated. It assumes that the user updates the time zone on his/her machine and if he doesn't it means she doesn't care, so why should you. (some travellers prefer to keep their portable machines set to their home-base time zone) Satyam Cheers, Rich -- Zend Certified Engineer http://www.corephp.co.uk Never trust a computer you can't throw out of a window -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- No virus found in this incoming message. Checked by AVG Free Edition. Version: 7.5.446 / Virus Database: 269.0.0/754 - Release Date: 09/04/2007 22:59 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Dates and different time zones
Satyam wrote: Store all of your dates as GMT. Perform all date based calculations around GMT also, and then offset the values for localised display only. This way you only need to store the GMT offsets for each user, i.e. GMT+1 or GMT-8 when it comes to displaying the dates to them. The trick is to use a constant base date for all data, and only being the user timezones into play when needed. Actually, I find that it is better not to bother storing anything for the user at all. At the first chance, get some JavaScript to read the local time of the client machine and send it back to the server, either with the login data, using some AJAX or along with any link the user might click on the welcome screen, for example, the language choice. Then use the offset from his local time to the server time for every time information, substract it from any time information you read from them, add it to anything you send them. This works whether the user is registered or not, whether he/she travels or remains in the same time zone and spares you the trouble of keeping your IP to country to timezone table updated. It assumes that the user updates the time zone on his/her machine and if he doesn't it means she doesn't care, so why should you. (some travellers prefer to keep their portable machines set to their home-base time zone) Of cause the major fault with this is that it can only display the CURRENT time offset. You *ALSO* need the users Daylight Saving Zone as well. This has been giving us great fun since the winter dates and times need a different offset to the summer ones. Something that simplistic browser time offset does not supply. :( The only way to get this working properly at present is to get the user to set their time/daylight settings in their profile, and then you can provide the correct offset for all days on a calendar. Remember that for users WITH a daylight saving offset, one day each year has 23 hours and one 25 hours ;) -- Lester Caine - G8HFL - Contact - http://home.lsces.co.uk/lsces/wiki/?page=contact L.S.Caine Electronic Services - http://home.lsces.co.uk MEDW - http://home.lsces.co.uk/ModelEngineersDigitalWorkshop/ Treasurer - Firebird Foundation Inc. - http://www.firebirdsql.org/index.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Dates and different time zones
- Original Message - From: Lester Caine [EMAIL PROTECTED] To: php-general@lists.php.net Sent: Tuesday, April 10, 2007 4:37 PM Subject: Re: [PHP] Dates and different time zones Satyam wrote: Store all of your dates as GMT. Perform all date based calculations around GMT also, and then offset the values for localised display only. This way you only need to store the GMT offsets for each user, i.e. GMT+1 or GMT-8 when it comes to displaying the dates to them. The trick is to use a constant base date for all data, and only being the user timezones into play when needed. Actually, I find that it is better not to bother storing anything for the user at all. At the first chance, get some JavaScript to read the local time of the client machine and send it back to the server, either with the login data, using some AJAX or along with any link the user might click on the welcome screen, for example, the language choice. Then use the offset from his local time to the server time for every time information, substract it from any time information you read from them, add it to anything you send them. This works whether the user is registered or not, whether he/she travels or remains in the same time zone and spares you the trouble of keeping your IP to country to timezone table updated. It assumes that the user updates the time zone on his/her machine and if he doesn't it means she doesn't care, so why should you. (some travellers prefer to keep their portable machines set to their home-base time zone) Of cause the major fault with this is that it can only display the CURRENT time offset. You *ALSO* need the users Daylight Saving Zone as well. This has been giving us great fun since the winter dates and times need a different offset to the summer ones. Something that simplistic browser time offset does not supply. :( The point is that you don't store the time offset in any user profile or anywhere but a session variable, which you keep for the duration of the session so it lasts only while the user is connected, whether logged in or not, profile or not. Next time he/she connects you get the new offset. If the time has changed due to daylight savings or the user travelling elsewhere, you'll get a new offset. The only time it fails is if the user is connected while the time switch is happening, but so will most of the clocks, watches and whatever is on at the time. Satyam The only way to get this working properly at present is to get the user to set their time/daylight settings in their profile, and then you can provide the correct offset for all days on a calendar. Remember that for users WITH a daylight saving offset, one day each year has 23 hours and one 25 hours ;) -- Lester Caine - G8HFL - Contact - http://home.lsces.co.uk/lsces/wiki/?page=contact L.S.Caine Electronic Services - http://home.lsces.co.uk MEDW - http://home.lsces.co.uk/ModelEngineersDigitalWorkshop/ Treasurer - Firebird Foundation Inc. - http://www.firebirdsql.org/index.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- No virus found in this incoming message. Checked by AVG Free Edition. Version: 7.5.446 / Virus Database: 269.0.0/754 - Release Date: 09/04/2007 22:59 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Dates and different time zones
Thanks for good answers. Okay, so I should set the default time zone to central GMT time, and then save GMT offset for every user. This sounds realistic, because I don't think that I need to correct the time for users that doesn't login. So, if I now have the GMT offset for every user, how do I display the right date? Can someone please show some phpcode? I would be very grateful if someone could do that. Satyam wrote: Store all of your dates as GMT. Perform all date based calculations around GMT also, and then offset the values for localised display only. This way you only need to store the GMT offsets for each user, i.e. GMT+1 or GMT-8 when it comes to displaying the dates to them. The trick is to use a constant base date for all data, and only being the user timezones into play when needed. Actually, I find that it is better not to bother storing anything for the user at all. At the first chance, get some JavaScript to read the local time of the client machine and send it back to the server, either with the login data, using some AJAX or along with any link the user might click on the welcome screen, for example, the language choice. Then use the offset from his local time to the server time for every time information, substract it from any time information you read from them, add it to anything you send them. This works whether the user is registered or not, whether he/she travels or remains in the same time zone and spares you the trouble of keeping your IP to country to timezone table updated. It assumes that the user updates the time zone on his/her machine and if he doesn't it means she doesn't care, so why should you. (some travellers prefer to keep their portable machines set to their home-base time zone) Of cause the major fault with this is that it can only display the CURRENT time offset. You *ALSO* need the users Daylight Saving Zone as well. This has been giving us great fun since the winter dates and times need a different offset to the summer ones. Something that simplistic browser time offset does not supply. :( The only way to get this working properly at present is to get the user to set their time/daylight settings in their profile, and then you can provide the correct offset for all days on a calendar. Remember that for users WITH a daylight saving offset, one day each year has 23 hours and one 25 hours ;) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Dates and different time zones
Niklas Karlsson wrote: Okay, so I should set the default time zone to central GMT time, and then save GMT offset for every user. This sounds realistic, because I don't think that I need to correct the time for users that doesn't login. So, if I now have the GMT offset for every user, how do I display the right date? Can someone please show some phpcode? I would be very grateful if someone could do that. It depends where the dates are coming from. My guess would be a database, and if so why not let MySQL do the work for you? SELECT date_created, DATE_SUB(date_created, INTERVAL 8 HOUR) AS offset_date from your_table The above assumes the users offset is -8 hours. Use DATE_ADD for GMT + values. Then you'll have both values in PHP - the actual original GMT date the date was created, and an offset date you can use for display. Or of course you can pluck just the GMT date out and start using PHP functions to convert to local timezones, etc. But if the shoe fits ... Cheers, Rich -- Zend Certified Engineer http://www.corephp.co.uk Never trust a computer you can't throw out of a window -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Dates and different time zones
Satyam wrote: Of cause the major fault with this is that it can only display the CURRENT time offset. You *ALSO* need the users Daylight Saving Zone as well. This has been giving us great fun since the winter dates and times need a different offset to the summer ones. Something that simplistic browser time offset does not supply. :( The point is that you don't store the time offset in any user profile or anywhere but a session variable, which you keep for the duration of the session so it lasts only while the user is connected, whether logged in or not, profile or not. Next time he/she connects you get the new offset. If the time has changed due to daylight savings or the user travelling elsewhere, you'll get a new offset. The only time it fails is if the user is connected while the time switch is happening, but so will most of the clocks, watches and whatever is on at the time. Please read what I wrote. The time offset from the browser is only of use to map CURRENT time. It is no use to display dates and times stored in the database that are reliant on the daylight saving offset. If TOMORROW is after the change in daylight saving, then the browser offset will not give you the right offset for tomorrows. The problem is convincing people that there *IS* a real problem, and trying to display the correct times JUST from a timezone offset is wrong for at least half of the year! You need to know that the time is changing tonight so that you can display tomorrows calendar correctly? -- Lester Caine - G8HFL - Contact - http://home.lsces.co.uk/lsces/wiki/?page=contact L.S.Caine Electronic Services - http://home.lsces.co.uk MEDW - http://home.lsces.co.uk/ModelEngineersDigitalWorkshop/ Treasurer - Firebird Foundation Inc. - http://www.firebirdsql.org/index.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Dates and different time zones
- Original Message - From: Niklas Karlsson [EMAIL PROTECTED] To: php-general@lists.php.net Sent: Tuesday, April 10, 2007 5:32 PM Subject: RE: [PHP] Dates and different time zones Thanks for good answers. Okay, so I should set the default time zone to central GMT time, and then save GMT offset for every user. This sounds realistic, because I don't think that I need to correct the time for users that doesn't login. Well, that was my whole point. If you store the GMT offsets for each user at a certain time in the year, they will turn invalid when they switch from daylight savings to no savings. Not all countries use daylight savings and even those that do don't switch at the same time. Furthermore, northern and southern hemispheres switch in opposite directions, if and when they do. If your users have to log in, that is the perfect time to read their current local time from the browser and keep it just for the session. Don't store it permanently. In PHP dates are stored as seconds from an arbitrary zero set at Jan 1st, 1970, so does MySql with date/time values though it shows them formatted but you can use the UNIX_TIMESTAMP function to get the actual timestamp. JavaScript uses milliseconds from the same base date. The rest is plain arithmetic. Satyam So, if I now have the GMT offset for every user, how do I display the right date? Can someone please show some phpcode? I would be very grateful if someone could do that. Satyam wrote: Store all of your dates as GMT. Perform all date based calculations around GMT also, and then offset the values for localised display only. This way you only need to store the GMT offsets for each user, i.e. GMT+1 or GMT-8 when it comes to displaying the dates to them. The trick is to use a constant base date for all data, and only being the user timezones into play when needed. Actually, I find that it is better not to bother storing anything for the user at all. At the first chance, get some JavaScript to read the local time of the client machine and send it back to the server, either with the login data, using some AJAX or along with any link the user might click on the welcome screen, for example, the language choice. Then use the offset from his local time to the server time for every time information, substract it from any time information you read from them, add it to anything you send them. This works whether the user is registered or not, whether he/she travels or remains in the same time zone and spares you the trouble of keeping your IP to country to timezone table updated. It assumes that the user updates the time zone on his/her machine and if he doesn't it means she doesn't care, so why should you. (some travellers prefer to keep their portable machines set to their home-base time zone) Of cause the major fault with this is that it can only display the CURRENT time offset. You *ALSO* need the users Daylight Saving Zone as well. This has been giving us great fun since the winter dates and times need a different offset to the summer ones. Something that simplistic browser time offset does not supply. :( The only way to get this working properly at present is to get the user to set their time/daylight settings in their profile, and then you can provide the correct offset for all days on a calendar. Remember that for users WITH a daylight saving offset, one day each year has 23 hours and one 25 hours ;) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- No virus found in this incoming message. Checked by AVG Free Edition. Version: 7.5.446 / Virus Database: 269.0.0/754 - Release Date: 09/04/2007 22:59 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Dates and different time zones
You are totally right, I am sorry. I would hate to miss my plane or train due to such mistake. Satyam - Original Message - From: Lester Caine [EMAIL PROTECTED] To: php-general@lists.php.net Sent: Tuesday, April 10, 2007 6:29 PM Subject: Re: [PHP] Dates and different time zones Satyam wrote: Of cause the major fault with this is that it can only display the CURRENT time offset. You *ALSO* need the users Daylight Saving Zone as well. This has been giving us great fun since the winter dates and times need a different offset to the summer ones. Something that simplistic browser time offset does not supply. :( The point is that you don't store the time offset in any user profile or anywhere but a session variable, which you keep for the duration of the session so it lasts only while the user is connected, whether logged in or not, profile or not. Next time he/she connects you get the new offset. If the time has changed due to daylight savings or the user travelling elsewhere, you'll get a new offset. The only time it fails is if the user is connected while the time switch is happening, but so will most of the clocks, watches and whatever is on at the time. Please read what I wrote. The time offset from the browser is only of use to map CURRENT time. It is no use to display dates and times stored in the database that are reliant on the daylight saving offset. If TOMORROW is after the change in daylight saving, then the browser offset will not give you the right offset for tomorrows. The problem is convincing people that there *IS* a real problem, and trying to display the correct times JUST from a timezone offset is wrong for at least half of the year! You need to know that the time is changing tonight so that you can display tomorrows calendar correctly? -- Lester Caine - G8HFL - Contact - http://home.lsces.co.uk/lsces/wiki/?page=contact L.S.Caine Electronic Services - http://home.lsces.co.uk MEDW - http://home.lsces.co.uk/ModelEngineersDigitalWorkshop/ Treasurer - Firebird Foundation Inc. - http://www.firebirdsql.org/index.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- No virus found in this incoming message. Checked by AVG Free Edition. Version: 7.5.446 / Virus Database: 269.0.0/754 - Release Date: 09/04/2007 22:59 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Dates and different time zones
On Tue, April 10, 2007 11:49 am, Satyam wrote: You are totally right, I am sorry. I would hate to miss my plane or train due to such mistake. Can somebody with way more karma than me put in an RFC to just NUKE daylight savings? Pretty please? Thanks! Whatever alleged benefits there are, they cannot possibly outweigh the drawbacks. Time zones at :15 intervals are bad enough! -- Some people have a gift link here. Know what I want? I want you to buy a CD from some indie artist. http://cdbaby.com/browse/from/lynch Yeah, I get a buck. So? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Dates and different time zones
On Tue, April 10, 2007 11:38 am, Satyam wrote: In PHP dates are stored as seconds from an arbitrary zero set at Jan 1st, 1970, so does MySql with date/time values though it shows them formatted but nitpick: I don't think MySQL uses Unix timestamp internally, as it's quite capable of storing a wider range than Unix timestamp. I could be wrong, of course, depending on what data type you were thinking of, and what version of MySQL, and what server settings are in effect... Databases have a bewildering plethora of date/time storage options. :-) -- Some people have a gift link here. Know what I want? I want you to buy a CD from some indie artist. http://cdbaby.com/browse/from/lynch Yeah, I get a buck. So? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Dates before 1970
Call me crazy, but I think that: $time = 0x; //largest INT possible echo date('m/d/Y h:i:s a', $time); would be very revealing. On Thu, April 13, 2006 10:26 pm, Suhas wrote: This will definitely solve one way but still other is there, How to get that -ve number which starts at 1/1/1900 at 00:00 AM = 0 I need to be able to convert back and forth as there are some calculations to be done on date field, But this is very interesting.. Thx SP On 4/13/06, Rasmus Lerdorf [EMAIL PROTECTED] wrote: Suhas wrote: Hello, I have a project that deals with the date time stamps since 1900 (and past), any suggestions about a good class that handles Date Time Format before 1970. I really like date() function and want something similar. date() uses Unix timestamps which on most Unix platforms goes from -MAX_INT to MAX_INT which means the date range is actually 12:45:52 12/13/1901 to 07:14:07 01/18/2038. So you might be able to get away with it. You can check it with: echo date(h:i:s m/d/Y,-2147483648); echo date(h:i:s m/d/Y, 2147483647); Windows, not being Unix, doesn't understand that the timestamp can be negative, although I think someone fixed that in PHP 5. In my 11+ years of PHP I have yet to run PHP on Windows, so I wouldn't know. -Rasmus -- Contact @ Suhas Pharkute. 208 830 8915 (C) 208 429 6943 (H) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- 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] Dates before 1970
At 6:43 PM -0500 4/17/06, Richard Lynch wrote: Call me crazy, but I think that: $time = 0x; //largest INT possible echo date('m/d/Y h:i:s a', $time); would be very revealing. H. Is: 12/31/1969 06:59:59 pm Yes, it is -- I remember what I was doing then. It was six months after I got out of the US Army. And, $time = -0x; //smallest INT possible echo date('m/d/Y h:i:s a', $time); Is: 12/13/1901 03:45:52 pm Close to when I was born. :-) Whereas, $time = 0; echo date('m/d/Y h:i:s a', $time); Is: 12/31/1969 07:00:00 pm But, what point is there in all this? tedd -- http://sperling.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Dates before 1970
Suhas wrote: Hello, I have a project that deals with the date time stamps since 1900 (and past), any suggestions about a good class that handles Date Time Format before 1970. I really like date() function and want something similar. date() uses Unix timestamps which on most Unix platforms goes from -MAX_INT to MAX_INT which means the date range is actually 12:45:52 12/13/1901 to 07:14:07 01/18/2038. So you might be able to get away with it. You can check it with: echo date(h:i:s m/d/Y,-2147483648); echo date(h:i:s m/d/Y, 2147483647); Windows, not being Unix, doesn't understand that the timestamp can be negative, although I think someone fixed that in PHP 5. In my 11+ years of PHP I have yet to run PHP on Windows, so I wouldn't know. -Rasmus -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Dates before 1970
This will definitely solve one way but still other is there, How to get that -ve number which starts at 1/1/1900 at 00:00 AM = 0 I need to be able to convert back and forth as there are some calculations to be done on date field, But this is very interesting.. Thx SP On 4/13/06, Rasmus Lerdorf [EMAIL PROTECTED] wrote: Suhas wrote: Hello, I have a project that deals with the date time stamps since 1900 (and past), any suggestions about a good class that handles Date Time Format before 1970. I really like date() function and want something similar. date() uses Unix timestamps which on most Unix platforms goes from -MAX_INT to MAX_INT which means the date range is actually 12:45:52 12/13/1901 to 07:14:07 01/18/2038. So you might be able to get away with it. You can check it with: echo date(h:i:s m/d/Y,-2147483648); echo date(h:i:s m/d/Y, 2147483647); Windows, not being Unix, doesn't understand that the timestamp can be negative, although I think someone fixed that in PHP 5. In my 11+ years of PHP I have yet to run PHP on Windows, so I wouldn't know. -Rasmus -- Contact @ Suhas Pharkute. 208 830 8915 (C) 208 429 6943 (H) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Dates before 1970
I have a project that deals with the date time stamps since 1900 (and past), any suggestions about a good class that handles Date Time Format before 1970. I really like date() function and want something similar. If you're using a database at all, most of them will handle any sort of dates. -- Postgresql php tutorials http://www.designmagick.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Dates problem
On Wednesday 27 April 2005 09:17, Mario de Frutos Dieguez wrote: Hi! I have a problem with dates. I have a function that sum a duration in laboral days to an initial date. The problem come when the function reaches the last sunday of October, the data remains in the last sunday of October and make an infinite loop. The functions works fine i have test in all the cases and only fails in the last sunday of October. So, let's see the function. Can anyone help me? Thanks in advance. PD: Jochem home english is bad english :P -- Mario de Frutos Dieguez División de Ingeniería del Software y Comunicaciones CARTIF -Parque Tecnológico Boecillo -- Cyberly yours, Petar Nedyalkov Devoted Orbitel Fan :-) PGP ID: 7AE45436 PGP Public Key: http://bu.orbitel.bg/pgp/bu.asc PGP Fingerprint: 7923 8D52 B145 02E8 6F63 8BDA 2D3F 7C0B 7AE4 5436 pgpcnojEYuGrX.pgp Description: PGP signature
Re: [PHP] Dates problem
Petar Nedyalkov escribió: On Wednesday 27 April 2005 09:17, Mario de Frutos Dieguez wrote: Hi! I have a problem with dates. I have a function that sum a duration in laboral days to an initial date. The problem come when the function reaches the last sunday of October, the data remains in the last sunday of October and make an infinite loop. The functions works fine i have test in all the cases and only fails in the last sunday of October. So, let's see the function. Can anyone help me? Thanks in advance. PD: Jochem home english is bad english :P -- Mario de Frutos Dieguez División de Ingeniería del Software y Comunicaciones CARTIF -Parque Tecnológico Boecillo function aCalculaFechas($oSqlBDGestion,$fecFechaIniProyecto,$iDuracion) { $iCont=0; //Descomponemos los argumentos y pasamos las fechas a formato Y/m/d $aFecIniTemp=split(/,$fecFechaIniProyecto); $fecFechaInicio=date(Y/m/d,mktime(0,0,0,$aFecIniTemp[1],$aFecIniTemp[0],$aFecIniTemp[2])); if ($iDuracion0) { //Generamos una fecha temporal sobre la que haremos los cálculos $fecFechaFinTemp=$fecFechaInicio; //Sumamos uno a la fecha para iniciar la cuenta de la duración un día despues de la fecha de inicio $fecFechaFinTemp=$this-SumarFechas($fecFechaFinTemp,1); //Ejecutamos un bucle que irá calculando la duración total (incluyendo sabados y domingos) a partir de la duración //laboral while ($iCont($iDuracion)) { //Obtenemos el día de la semana del día que estamos mirando $aFecTempCalculo=split('/',$fecFechaFinTemp); $iDiaSemanaTemp=date(w,mktime(0,0,0,$aFecTempCalculo[1],$aFecTempCalculo[2],$aFecTempCalculo[0])); //Si el día es distinto de domingo o sabado aumentamos el contador de duración laboral if ($iDiaSemanaTemp!=6 $iDiaSemanaTemp!=0) { $iCont++; } //Se añade uno más a la fecha $fecFechaFinTemp=$this-SumarFechas($fecFechaFinTemp,1); //Siempre se añade uno al número de días totales. $iNumDiasTotales++; //echo $iNumDiasTotales.'br'; } //Sumamos al a fecha temporal el número de dias totales (solo incluidos sabados y domingos) $fecFechaFinTemp=$this-SumarFechas($fecFechaInicio,$iNumDiasTotales); //Hacemos un bucle obteniendo los días festivos usando la fecha final temporal y hasta que no se obtengan dias //festivos sigue sumandolos. do { //echo SELECT * FROM festivos WHERE dia_festivo BETWEEN '.$fecFechaInicio.' AND '.$fecFechaFinTemp.'; //Obtenemos los dias festivos entre el rango de fechas $iObtenDiasFest=$oSqlBDGestion-iEjecutarConsulta(SELECT * FROM festivos WHERE dia_festivo BETWEEN '.$fecFechaInicio.' AND '.$fecFechaFinTemp.'); $iNumDiasFestivos=$oSqlBDGestion-iNumeroFilasResultadoConsulta($iObtenDiasFest); $fecFechaInicio=$this-SumarFechas($fecFechaFinTemp,1); $fecFechaFinTemp=$this-SumarFechas($fecFechaFinTemp,$iNumDiasFestivos); }while ($iNumDiasFestivos0); $aFecTempCalculo=split('/',$fecFechaFinTemp); $iDiaSemanaTemp=date(w,mktime(0,0,0,$aFecTempCalculo[1],$aFecTempCalculo[2],$aFecTempCalculo[0])); if ($iDiaSemanaTemp==6) $fecFechaFin=$this-SumarFechas($fecFechaFinTemp,3); else if ($iDiaSemanaTemp==0) $fecFechaFin=$this-SumarFechas($fecFechaFinTemp,2); else $fecFechaFin=$fecFechaFinTemp; $aFecFin=split(/,$fecFechaFin); $fecFechaFin=date(d/m/Y,mktime(0,0,0,$aFecFin[1],$aFecFin[2],$aFecFin[0])); } else $fecFechaFin=$fecFechaIniProyecto; return $fecFechaFin; } -- Mario de Frutos Dieguez División de Ingeniería del Software y Comunicaciones CARTIF -Parque Tecnológico Boecillo -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Dates then 1970
Mark McCulligh wrote: What function(s) would you use if you want to take someone's birth day and format it on display. I have always used strtotime, then strftime but it doesn't work if someone was born in 1939. strtotime returns -1. What function would you use to take the input string 1939/11/23 and get the timestamp so I can use functions like strftime or date. You'll have to tear it apart and do the math youself. Current year minus the first four digits. If current month/day is less than month/day from string, then subtract one (hasn't reached birthday yet). If you're storing these dates in a database, you can use your query to calculate the age (unless it used unix timestamps, also). -- ---John Holmes... Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/ php|architect: The Magazine for PHP Professionals www.phparch.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Dates
Ok, Mayve I need to be a little clear, I under the link below as showing dates. What I need to know how can I take the input of 09-12-1967 and have enter into a mysql data using php as 1967-09-12? Because everything that is past from my form to mysql is not the way it was enter. Would I need to create three fields month, day, year, then take those three into -mm-dd? If so how? Chuck Jay Blanchard wrote: [snip] This might be mysql question but how can I change a US format date (mm/dd/) to a MySQL Format (/mm/dd). Can I do this will php or will need let say javascript or perl to do this? [/snip] date(y/m/d); RTFM at http://www.php.net/date -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Dates
[snip] Ok, Mayve I need to be a little clear, I under the link below as showing dates. What I need to know how can I take the input of 09-12-1967 and have enter into a mysql data using php as 1967-09-12? Because everything that is past from my form to mysql is not the way it was enter. Would I need to create three fields month, day, year, then take those three into -mm-dd? If so how? [/snip] Aha. $theOldDate = 09-12-1967; $theNewDate = substr($theOldDate, 6, 4).-.substr($theOldDate, 0, 2).-.substr($theOldDate, 3, 2); echo $theNewDate; -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Dates
Also, an option is to have that SQL field set as date. With postgres, I can insert 09-12-1967 and the sql server auto converts it to 1967-09-12 upon saving into date field. However, another way is.. ? $date=09-12-1967; $dARR=explode(-, $date); $tmon=$dARR[0]; $tday=$dARR[1]; $tyr=$dARR[2]; $newdate=$tyr-$tmon-$tday; ? Jay Blanchard wrote: [snip] Ok, Mayve I need to be a little clear, I under the link below as showing dates. What I need to know how can I take the input of 09-12-1967 and have enter into a mysql data using php as 1967-09-12? Because everything that is past from my form to mysql is not the way it was enter. Would I need to create three fields month, day, year, then take those three into -mm-dd? If so how? [/snip] Aha. $theOldDate = 09-12-1967; $theNewDate = substr($theOldDate, 6, 4).-.substr($theOldDate, 0, 2).-.substr($theOldDate, 3, 2); echo $theNewDate; -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Dates
[snip] This might be mysql question but how can I change a US format date (mm/dd/) to a MySQL Format (/mm/dd). Can I do this will php or will need let say javascript or perl to do this? [/snip] date(y/m/d); RTFM at http://www.php.net/date -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Dates
date(Y-m-d, strtotime($your_date)) Payne wrote: Hi , This might be mysql question but how can I change a US format date (mm/dd/) to a MySQL Format (/mm/dd). Can I do this will php or will need let say javascript or perl to do this? Payne -- 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] dates greater than 2002-01-18 create error
[snip] Anytime I try to add a day to the date 2002-01-18, I get a Warning: unexpected error in date() error. Can anyone shed some light on this. [/snip] If you'll shed some code on this, we'll shed some help :^] Jay -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] dates greater than 2002-01-18 create error
[snip] ? $day = 2038-01-19; $day_temp = date(d, strtotime($day)); $month_temp = date(m, strtotime($day)); $year_temp = date(Y, strtotime($day)); $temp_date = mktime (0,0,0,$month_temp ,$day_temp+1 ,$year_temp); echo date (Y-m-d, $temp_date); ? [/snip] I take out '+1' and the result is 1969-12-31 I put in the '+1' and the result is 1970-01-01 I change '2038-01-19' to '2002-01-19' and it works. Which is what the subject of your message was, not [PHP] dates greater than 2038-01-18 create error HTH! Jay -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] dates greater than 2002-01-18 create error
Dude, did you read the PHP Date manual page? I quote: Note: The valid range of a timestamp is typically from Fri, 13 Dec 1901 20:45:54 GMT to Tue, 19 Jan 2038 03:14:07 GMT. (These are the dates that correspond to the minimum and maximum values for a 32-bit signed integer). On windows this range is limited from 01-01-1970 to 19-01-2038. Adam Voigt [EMAIL PROTECTED] On Mon, 2002-08-12 at 12:23, Jay Blanchard wrote: [snip] ? $day = 2038-01-19; $day_temp = date(d, strtotime($day)); $month_temp = date(m, strtotime($day)); $year_temp = date(Y, strtotime($day)); $temp_date = mktime (0,0,0,$month_temp ,$day_temp+1 ,$year_temp); echo date (Y-m-d, $temp_date); ? [/snip] I take out '+1' and the result is 1969-12-31 I put in the '+1' and the result is 1970-01-01 I change '2038-01-19' to '2002-01-19' and it works. Which is what the subject of your message was, not [PHP] dates greater than 2038-01-18 create error HTH! Jay -- 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] dates greater than 2002-01-18 create error
right am i missing something or is that not just an other Y2K bug waiting to happen? Not that I plan to be coding php in 2038 but my kids might be.:-P John - Original Message - From: Adam Voigt [EMAIL PROTECTED] To: Jay Blanchard [EMAIL PROTECTED] Cc: [EMAIL PROTECTED] Sent: Monday, August 12, 2002 5:26 PM Subject: RE: [PHP] dates greater than 2002-01-18 create error Dude, did you read the PHP Date manual page? I quote: Note: The valid range of a timestamp is typically from Fri, 13 Dec 1901 20:45:54 GMT to Tue, 19 Jan 2038 03:14:07 GMT. (These are the dates that correspond to the minimum and maximum values for a 32-bit signed integer). On windows this range is limited from 01-01-1970 to 19-01-2038. Adam Voigt [EMAIL PROTECTED] On Mon, 2002-08-12 at 12:23, Jay Blanchard wrote: [snip] ? $day = 2038-01-19; $day_temp = date(d, strtotime($day)); $month_temp = date(m, strtotime($day)); $year_temp = date(Y, strtotime($day)); $temp_date = mktime (0,0,0,$month_temp ,$day_temp+1 ,$year_temp); echo date (Y-m-d, $temp_date); ? [/snip] I take out '+1' and the result is 1969-12-31 I put in the '+1' and the result is 1970-01-01 I change '2038-01-19' to '2002-01-19' and it works. Which is what the subject of your message was, not [PHP] dates greater than 2038-01-18 create error HTH! Jay -- 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] dates greater than 2002-01-18 create error
It's a fairly well known problem now but I'm sure we'll all be using (at least) 64bit integers for storing this sort of stuff by 2038. FYI, the current 32bit signed int allows for around 68years - a 64bit signed int will give us a few billion years :) Danny. - Original Message - From: John Wards [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Monday, August 12, 2002 5:32 PM Subject: Re: [PHP] dates greater than 2002-01-18 create error right am i missing something or is that not just an other Y2K bug waiting to happen? Not that I plan to be coding php in 2038 but my kids might be.:-P John - Original Message - From: Adam Voigt [EMAIL PROTECTED] To: Jay Blanchard [EMAIL PROTECTED] Cc: [EMAIL PROTECTED] Sent: Monday, August 12, 2002 5:26 PM Subject: RE: [PHP] dates greater than 2002-01-18 create error Dude, did you read the PHP Date manual page? I quote: Note: The valid range of a timestamp is typically from Fri, 13 Dec 1901 20:45:54 GMT to Tue, 19 Jan 2038 03:14:07 GMT. (These are the dates that correspond to the minimum and maximum values for a 32-bit signed integer). On windows this range is limited from 01-01-1970 to 19-01-2038. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Dates and Date()
$ts = strtotime(-10 days); On Mon, 29 Jul 2002, Christopher J. Crane wrote: I believethisto be one way to find out yesterday's date: $tomorrow = mktime (0,0,0,date(m) ,date(d)-1,date(Y)); However, I would like to have a snippet of code to tell me how to get the date of today - 10 days ago. if today is jul 29, 2002, how do I get the date funtion to tell me 10 days ago. with jul 29, 2002 as the date it would be easy, just subtract 10 from 29, but what happens if the date was jul 2, 2002. How do I get the correct date returned -- 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] Dates and Date()
On Mon, Jul 29, 2002 at 10:51:39AM -0400, Christopher J. Crane wrote: I believethisto be one way to find out yesterday's date: $tomorrow = mktime (0,0,0,date(m) ,date(d)-1,date(Y)); However, I would like to have a snippet of code to tell me how to get the date of today - 10 days ago. You have a working example of how to get yesterday. Did you even try to rework it to get ten days ago by substituting -10 for -1? What happened? --Dan -- PHP classes that make web design easier SQL Solution | Layout Solution | Form Solution sqlsolution.info | layoutsolution.info | formsolution.info T H E A N A L Y S I S A N D S O L U T I O N S C O M P A N Y 4015 7 Av #4AJ, Brooklyn NY v: 718-854-0335 f: 718-854-0409 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Dates and Date()
- Original Message - From: Christopher J. Crane [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Monday, July 29, 2002 5:51 PM Subject: [PHP] Dates and Date() I believethisto be one way to find out yesterday's date: $tomorrow = mktime (0,0,0,date(m) ,date(d)-1,date(Y)); However, I would like to have a snippet of code to tell me how to get the date of today - 10 days ago. if today is jul 29, 2002, how do I get the date funtion to tell me 10 days ago. with jul 29, 2002 as the date it would be easy, just subtract 10 from 29, but what happens if the date was jul 2, 2002. How do I get the correct date returned All date functions handle correctly this case so echo strftime('%m:%d:%Y', gmmktime(0,0,0,7,2-10,2002)); will be: 06:22:2002 You can add/substract what you wish and will get correct results in case the the resulting timestamp is between 1.1.1970 and somewhere in year 2038. Best regards, Andrey Hristov -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Dates and Date()
Ok here is what I did. $Hist_Time = gmstrftime('%m:%d:%Y', strtotime(-10 days)); Now I am wondering if there is a way to look for only the last day business days and be returned in an array? - Original Message - From: Andrey Hristov [EMAIL PROTECTED] To: Christopher J. Crane [EMAIL PROTECTED] Cc: [EMAIL PROTECTED] Sent: Monday, July 29, 2002 10:59 AM Subject: Re: [PHP] Dates and Date() - Original Message - From: Christopher J. Crane [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Monday, July 29, 2002 5:51 PM Subject: [PHP] Dates and Date() I believethisto be one way to find out yesterday's date: $tomorrow = mktime (0,0,0,date(m) ,date(d)-1,date(Y)); However, I would like to have a snippet of code to tell me how to get the date of today - 10 days ago. if today is jul 29, 2002, how do I get the date funtion to tell me 10 days ago. with jul 29, 2002 as the date it would be easy, just subtract 10 from 29, but what happens if the date was jul 2, 2002. How do I get the correct date returned All date functions handle correctly this case so echo strftime('%m:%d:%Y', gmmktime(0,0,0,7,2-10,2002)); will be: 06:22:2002 You can add/substract what you wish and will get correct results in case the the resulting timestamp is between 1.1.1970 and somewhere in year 2038. Best regards, Andrey Hristov -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Dates and Date()
Use while() with some counter that increments when you have bussiness day/ $counter = 0; $bdays = 0; while ($bdays10){ if (in_array(gmstrftime('%u',gmmktime(0,0,0,7,2-($counter++),2002),array(1,2,3, 4,5)){ $bdays++; echo gmstrftime('%m/%d/%Y',gmmktime(0,0,0,7,2-($counter-1),2002); } } HTH Regards, Andrey - Original Message - From: Christopher J. Crane [EMAIL PROTECTED] To: Andrey Hristov [EMAIL PROTECTED] Cc: [EMAIL PROTECTED] Sent: Monday, July 29, 2002 7:00 PM Subject: Re: [PHP] Dates and Date() Ok here is what I did. $Hist_Time = gmstrftime('%m:%d:%Y', strtotime(-10 days)); Now I am wondering if there is a way to look for only the last day business days and be returned in an array? - Original Message - From: Andrey Hristov [EMAIL PROTECTED] To: Christopher J. Crane [EMAIL PROTECTED] Cc: [EMAIL PROTECTED] Sent: Monday, July 29, 2002 10:59 AM Subject: Re: [PHP] Dates and Date() - Original Message - From: Christopher J. Crane [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Monday, July 29, 2002 5:51 PM Subject: [PHP] Dates and Date() I believethisto be one way to find out yesterday's date: $tomorrow = mktime (0,0,0,date(m) ,date(d)-1,date(Y)); However, I would like to have a snippet of code to tell me how to get the date of today - 10 days ago. if today is jul 29, 2002, how do I get the date funtion to tell me 10 days ago. with jul 29, 2002 as the date it would be easy, just subtract 10 from 29, but what happens if the date was jul 2, 2002. How do I get the correct date returned All date functions handle correctly this case so echo strftime('%m:%d:%Y', gmmktime(0,0,0,7,2-10,2002)); will be: 06:22:2002 You can add/substract what you wish and will get correct results in case the the resulting timestamp is between 1.1.1970 and somewhere in year 2038. Best regards, Andrey Hristov -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Dates and Date()
very nice... thank you! - Original Message - From: Andrey Hristov [EMAIL PROTECTED] To: Christopher J. Crane [EMAIL PROTECTED] Cc: [EMAIL PROTECTED] Sent: Monday, July 29, 2002 12:04 PM Subject: Re: [PHP] Dates and Date() Use while() with some counter that increments when you have bussiness day/ $counter = 0; $bdays = 0; while ($bdays10){ if (in_array(gmstrftime('%u',gmmktime(0,0,0,7,2-($counter++),2002),array(1,2,3, 4,5)){ $bdays++; echo gmstrftime('%m/%d/%Y',gmmktime(0,0,0,7,2-($counter-1),2002); } } HTH Regards, Andrey - Original Message - From: Christopher J. Crane [EMAIL PROTECTED] To: Andrey Hristov [EMAIL PROTECTED] Cc: [EMAIL PROTECTED] Sent: Monday, July 29, 2002 7:00 PM Subject: Re: [PHP] Dates and Date() Ok here is what I did. $Hist_Time = gmstrftime('%m:%d:%Y', strtotime(-10 days)); Now I am wondering if there is a way to look for only the last day business days and be returned in an array? - Original Message - From: Andrey Hristov [EMAIL PROTECTED] To: Christopher J. Crane [EMAIL PROTECTED] Cc: [EMAIL PROTECTED] Sent: Monday, July 29, 2002 10:59 AM Subject: Re: [PHP] Dates and Date() - Original Message - From: Christopher J. Crane [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Monday, July 29, 2002 5:51 PM Subject: [PHP] Dates and Date() I believethisto be one way to find out yesterday's date: $tomorrow = mktime (0,0,0,date(m) ,date(d)-1,date(Y)); However, I would like to have a snippet of code to tell me how to get the date of today - 10 days ago. if today is jul 29, 2002, how do I get the date funtion to tell me 10 days ago. with jul 29, 2002 as the date it would be easy, just subtract 10 from 29, but what happens if the date was jul 2, 2002. How do I get the correct date returned All date functions handle correctly this case so echo strftime('%m:%d:%Y', gmmktime(0,0,0,7,2-10,2002)); will be: 06:22:2002 You can add/substract what you wish and will get correct results in case the the resulting timestamp is between 1.1.1970 and somewhere in year 2038. Best regards, Andrey Hristov -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Dates and Date()
Ok here is what I did. $Hist_Time = gmstrftime('%m:%d:%Y', strtotime(-10 days)); Now I am wondering if there is a way to look for only the last day business days and be returned in an array? What have you tried? How much longer do we have to hold your hand? Not to be too rude or anything, but at least give it a few tries on your own, then post your code, what you thought would happen, what actually happened, and what help you need. That's how these things are supposed to work... ---John Holmes... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Dates and Date()
No problema. If you have access to icq you can use irc.php.net or capek.openprojects.net (or any other openproject's irc server) on #php channel. Andrey - Original Message - From: Christopher J. Crane [EMAIL PROTECTED] To: Andrey Hristov [EMAIL PROTECTED] Cc: [EMAIL PROTECTED] Sent: Monday, July 29, 2002 7:08 PM Subject: Re: [PHP] Dates and Date() very nice... thank you! - Original Message - From: Andrey Hristov [EMAIL PROTECTED] To: Christopher J. Crane [EMAIL PROTECTED] Cc: [EMAIL PROTECTED] Sent: Monday, July 29, 2002 12:04 PM Subject: Re: [PHP] Dates and Date() Use while() with some counter that increments when you have bussiness day/ $counter = 0; $bdays = 0; while ($bdays10){ if (in_array(gmstrftime('%u',gmmktime(0,0,0,7,2-($counter++),2002),array(1,2,3, 4,5)){ $bdays++; echo gmstrftime('%m/%d/%Y',gmmktime(0,0,0,7,2-($counter-1),2002); } } HTH Regards, Andrey - Original Message - From: Christopher J. Crane [EMAIL PROTECTED] To: Andrey Hristov [EMAIL PROTECTED] Cc: [EMAIL PROTECTED] Sent: Monday, July 29, 2002 7:00 PM Subject: Re: [PHP] Dates and Date() Ok here is what I did. $Hist_Time = gmstrftime('%m:%d:%Y', strtotime(-10 days)); Now I am wondering if there is a way to look for only the last day business days and be returned in an array? - Original Message - From: Andrey Hristov [EMAIL PROTECTED] To: Christopher J. Crane [EMAIL PROTECTED] Cc: [EMAIL PROTECTED] Sent: Monday, July 29, 2002 10:59 AM Subject: Re: [PHP] Dates and Date() - Original Message - From: Christopher J. Crane [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Monday, July 29, 2002 5:51 PM Subject: [PHP] Dates and Date() I believethisto be one way to find out yesterday's date: $tomorrow = mktime (0,0,0,date(m) ,date(d)-1,date(Y)); However, I would like to have a snippet of code to tell me how to get the date of today - 10 days ago. if today is jul 29, 2002, how do I get the date funtion to tell me 10 days ago. with jul 29, 2002 as the date it would be easy, just subtract 10 from 29, but what happens if the date was jul 2, 2002. How do I get the correct date returned All date functions handle correctly this case so echo strftime('%m:%d:%Y', gmmktime(0,0,0,7,2-10,2002)); will be: 06:22:2002 You can add/substract what you wish and will get correct results in case the the resulting timestamp is between 1.1.1970 and somewhere in year 2038. Best regards, Andrey Hristov -- 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] Dates and Date()
The guy just wanted fast help. It is obvious that he is not advanced it time transformations and functions. I think that he didn't ask bad question. WHich are bad - his questions or What the is php?. When he has more time he will take better look at the docs :)) Some people always experiment some not. Kind regards, Andrey Hristov - Original Message - From: 1LT John W. Holmes [EMAIL PROTECTED] To: Christopher J. Crane [EMAIL PROTECTED]; Andrey Hristov [EMAIL PROTECTED] Cc: [EMAIL PROTECTED] Sent: Monday, July 29, 2002 7:12 PM Subject: Re: [PHP] Dates and Date() Ok here is what I did. $Hist_Time = gmstrftime('%m:%d:%Y', strtotime(-10 days)); Now I am wondering if there is a way to look for only the last day business days and be returned in an array? What have you tried? How much longer do we have to hold your hand? Not to be too rude or anything, but at least give it a few tries on your own, then post your code, what you thought would happen, what actually happened, and what help you need. That's how these things are supposed to work... ---John Holmes... -- 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] Dates and Date()
Maybe. You just see if to much around here where people will ask a lot of questions without ever doing any work themselves. Sometimes they get lucky and get an answer, sometimes they don't. I'm just trying to teach the guy not to take what he's getting here for granted... Either way, I'm glad you helped him and he got it figured out... ---John Holmes... - Original Message - From: Andrey Hristov [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Monday, July 29, 2002 12:17 PM Subject: Re: [PHP] Dates and Date() The guy just wanted fast help. It is obvious that he is not advanced it time transformations and functions. I think that he didn't ask bad question. WHich are bad - his questions or What the is php?. When he has more time he will take better look at the docs :)) Some people always experiment some not. Kind regards, Andrey Hristov - Original Message - From: 1LT John W. Holmes [EMAIL PROTECTED] To: Christopher J. Crane [EMAIL PROTECTED]; Andrey Hristov [EMAIL PROTECTED] Cc: [EMAIL PROTECTED] Sent: Monday, July 29, 2002 7:12 PM Subject: Re: [PHP] Dates and Date() Ok here is what I did. $Hist_Time = gmstrftime('%m:%d:%Y', strtotime(-10 days)); Now I am wondering if there is a way to look for only the last day business days and be returned in an array? What have you tried? How much longer do we have to hold your hand? Not to be too rude or anything, but at least give it a few tries on your own, then post your code, what you thought would happen, what actually happened, and what help you need. That's how these things are supposed to work... ---John Holmes... -- 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] Dates and Date()
Since you leave your name as 1LT, I am assuming that means 1st LT in what branch of the service...Army probably and the reserves no less. I am working on a huge project and write lets of code. Mostly MySql stuff. I did not know how to do this so I asked. Two people were nice enough to help out. It seems you are stuck on yourself and thought I was asking you. There are many levels in this list with over 11000 posts. Some people help people because others ask for it. If I wanted you opinion, I would have asked for it. I have received 11 emails from this list about your post and all thought you were being a jerk. If you didn't like what I was asking for you could have simply not read it or responded. Instead, you post your opinion to the entire group. You could have just sent it to me directly. It's people like you who intimidate others from sending a post or worse replying to someone in fear of someone like you who thinks they are better then everyone else. The name of this list is not EXPERTS or Only after you tried several times it is general. - Original Message - From: 1LT John W. Holmes [EMAIL PROTECTED] To: Christopher J. Crane [EMAIL PROTECTED]; Andrey Hristov [EMAIL PROTECTED] Cc: [EMAIL PROTECTED] Sent: Monday, July 29, 2002 12:12 PM Subject: Re: [PHP] Dates and Date() Ok here is what I did. $Hist_Time = gmstrftime('%m:%d:%Y', strtotime(-10 days)); Now I am wondering if there is a way to look for only the last day business days and be returned in an array? What have you tried? How much longer do we have to hold your hand? Not to be too rude or anything, but at least give it a few tries on your own, then post your code, what you thought would happen, what actually happened, and what help you need. That's how these things are supposed to work... ---John Holmes... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Dates and Date()
Thank you again. Andrey Hristov [EMAIL PROTECTED] wrote in message 01ec01c2371b$77d35b20$1601a8c0@nik">news:01ec01c2371b$77d35b20$1601a8c0@nik... The guy just wanted fast help. It is obvious that he is not advanced it time transformations and functions. I think that he didn't ask bad question. WHich are bad - his questions or What the is php?. When he has more time he will take better look at the docs :)) Some people always experiment some not. Kind regards, Andrey Hristov - Original Message - From: 1LT John W. Holmes [EMAIL PROTECTED] To: Christopher J. Crane [EMAIL PROTECTED]; Andrey Hristov [EMAIL PROTECTED] Cc: [EMAIL PROTECTED] Sent: Monday, July 29, 2002 7:12 PM Subject: Re: [PHP] Dates and Date() Ok here is what I did. $Hist_Time = gmstrftime('%m:%d:%Y', strtotime(-10 days)); Now I am wondering if there is a way to look for only the last day business days and be returned in an array? What have you tried? How much longer do we have to hold your hand? Not to be too rude or anything, but at least give it a few tries on your own, then post your code, what you thought would happen, what actually happened, and what help you need. That's how these things are supposed to work... ---John Holmes... -- 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] Dates
On Tue, 28 May 2002, Jeroen Timmers wrote: 2002-10-9 and 2002-11-16 Is there a function to see how many day's between thore date's is? (strtotime($date1) - strtotime($date2)) / 86400 miguel -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Dates
Something like this.. $start = 2002-10-9; $end = 2002-11-16; $arStart = explode(-, $start); $arEnd = explode(-, $end); $startTime = date(U, mktime(0,0,0,$arStart[1], $arStart[2], $arStart[0])); $endTime = date(U, mktime(0,0,0,$arEnd[1], $arEnd[2], $arEnd[0])); $dif = $endTime - $startTime; // in seconds That will do it but you could simplfy it with some more advanced techniques. -Jared -Original Message- From: Jeroen Timmers [mailto:[EMAIL PROTECTED]] Sent: Tuesday, May 28, 2002 2:17 PM To: [EMAIL PROTECTED] Subject: [PHP] Dates i have two dates for example 2002-10-9 and 2002-11-16 Is there a function to see how many day's between thore date's is? Jeroen -- 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] Dates
PHP way: Use strtotime() to get a unix timestamp for each one. subtract smaller from larger and divide by number of seconds in a day. MySQL way: I assume these dates come from a database. Use a query like this: SELECT TO_DAYS(column_one) - TO_DAYS(column_two) AS Difference FROM table WHERE ... Then you'll have a column 'Difference' in your result that contains the difference between the two dates in days. ---John Holmes... - Original Message - From: Jeroen Timmers [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Tuesday, May 28, 2002 2:16 PM Subject: [PHP] Dates i have two dates for example 2002-10-9 and 2002-11-16 Is there a function to see how many day's between thore date's is? Jeroen -- 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] dates only in the future
I'm looking for a function which enables me to allow user only to enter those dates which are still to come. In my head I have three select things... one for day, one for month and one for year. In order to prevent the user from submitting the form with the date which is in past, I need probably Javascript. Am I correct? Only if you want to check before the form gets submitted... I rather prefer to keep my site Javascript free and therefore it would be great if somebody has already written such a function and would be ready to share it with me/others. If not, any ideas how to start... Here is a function I use. Call after the form is submitted. function verifyDate( $date_month, $date_day, $date_year, $notprior = ) { // v. 1.1 // 1999.11.19 - to check to make sure that the selected dates are // within the appropriate range: // ie. days cannot exceed 31, months cannot exceed 12 and // years cannot be more than 10 years in the future. $retval = 1; $today = MkTime(0,0,0, date( m ), date( d ), date( Y )); $selected_date = MkTime(0,0,0, $date_month, $date_day,$date_year); if(( $date_month 12 ) || ( $date_day 31 ) || (( $date_year ( date( Y ) - 95 )) || ( $date_year date( Y { $dategood = 0; } else { $dategood = checkdate( $date_month, $date_day, $date_year ); } if( !$dategood ) { $retval = Date is invalid. Please make sure that the day selected is valid for the month selectedbr\n; } elseif (( $today $selected_date ) ( $notprior )) { $retval = Date Selected Is Prior To Todaybr\n; } return $retval; } // End function verifyDate(); Chris
Re: [PHP] dates
In article [EMAIL PROTECTED], [EMAIL PROTECTED] ("Alvin Tan") wrote: a little stuck here. trying to pull a bunch of unix timestamps out and show only those that show up today. problem is that when i hit the first match, the rest of the dates don't show. code follows: == $sql = "SELECT * FROM dates"; $result = mysql_query($sql) or mysql_die(); while ($a = mysql_fetch_array($result)) $showsID = $a[showsID]; $ts = $a[timestamp]; $endTime=(spanDay ($ts)); // function that adds 24hrs to initial stamp to make the end of day time. $today = time(); if (($endTime = $today)($ts = $today)) { $sq = "SELECT * FROM shows WHERE id=$showsID"; $result = mysql_query($sq) or mysql_die(); $b = mysql_fetch_array($result); print "brfont color=red$b[name]/fontbr"; } } Which of the queries are you concerned with, 'cuz on that second query you're only fetching array $b once. Wrap a while() loop around it like you did with array $a if you want more rows. BTW, you're missing an opening curly brace for the first while(). -- CC -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
RE: [PHP] dates
Why don't you look into mYSQL documentation and rewrite your queries, you might be able to end up with one only single query and 3 lines of PHP, instead of the whole bunch as you're trying to do. The reason I advise you that is that mySQL plays some really sweet games with dates, while PHP treats them as simple set of integers... Hope it helps. Sincerely, Maxim Maletsky Founder, Chief Developer PHPBeginner.com (Where PHP Begins) [EMAIL PROTECTED] www.phpbeginner.com -Original Message- From: Alvin Tan [mailto:[EMAIL PROTECTED]] Sent: Monday, April 16, 2001 4:21 PM To: Php-General Subject: [PHP] dates hi all, a little stuck here. trying to pull a bunch of unix timestamps out and show only those that show up today. problem is that when i hit the first match, the rest of the dates don't show. code follows: == $sql = "SELECT * FROM dates"; $result = mysql_query($sql) or mysql_die(); while ($a = mysql_fetch_array($result)) $showsID = $a[showsID]; $ts = $a[timestamp]; $endTime=(spanDay ($ts)); // function that adds 24hrs to initial stamp to make the end of day time. $today = time(); if (($endTime = $today)($ts = $today)) { $sq = "SELECT * FROM shows WHERE id=$showsID"; $result = mysql_query($sq) or mysql_die(); $b = mysql_fetch_array($result); print "brfont color=red$b[name]/fontbr"; } } == thanks in advance, @lvin -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
RE: [PHP] dates from db
If it's stored as a unix timestamp you can format it any way you like. [www.php.net/date] If it's stored as a string in the -MM-DD hh:mm:ss format, you can use substr(0,10) [www.php.net/substr] to get the first 10 characters and only display those. HTH Jon -Original Message- From: Matt Davis [mailto:[EMAIL PROTECTED]] Sent: 07 March 2001 13:35 To: Php Mailing List Subject: [PHP] dates from db I am calling on a number of fields from my db one of which is a date. When the date displays it is in the following format -MM-DD 00:00:00 I Want it to only display the date and not the time like this -MM-DD Is it possible to remove the time when calling on it from the db can anyone help? Thanks Matt. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] ** 'The information included in this Email is of a confidential nature and is intended only for the addressee. If you are not the intended addressee, any disclosure, copying or distribution by you is prohibited and may be unlawful. Disclosure to any party other than the addressee, whether inadvertent or otherwise is not intended to waive privilege or confidentiality' ** -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
RE: [PHP] dates from db
-Original Message- From: Matt Davis [mailto:[EMAIL PROTECTED]] Sent: Wednesday, March 07, 2001 7:35 AM To: Php Mailing List Subject: [PHP] dates from db I am calling on a number of fields from my db one of which is a date. When the date displays it is in the following format -MM-DD 00:00:00 I Want it to only display the date and not the time like this -MM-DD Is it possible to remove the time when calling on it from the db Check the documentation for the database engine you're using. MySQL, for example, has a date_format() function that you can use in your query to specify what information you'd like displayed from a date/time field, and how you'd like it presented. --- Mark Roedel ([EMAIL PROTECTED]) || "There cannot be a crisis next week. Systems Programmer / WebMaster || My schedule is already full." LeTourneau University ||-- Henry Kissinger -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
RE: [PHP] dates from db
My own solution to this is a bit more complex but it seems to work with both of the databases I work with. MySQL and Postgress. for example I would use 'select *,unix_timestamp(cr_date) as my_cr_date from table where ref_index=2345;' Then when I go to output it I can use the unix date command such as '$string=date("l dS of F Y h:i:s A",db-f(my_cr_date)); My reference to db-f(my_cr_date) is my phplib methof of reading the data. You may use your own method. Doing it this way you can get your own method of displaying dates or times in almost any way you want. And you don;t have to count on your database supporting it. "Mark Roedel" [EMAIL PROTECTED] 03/07/01 09:08AM -Original Message- From: Matt Davis [mailto:[EMAIL PROTECTED]] Sent: Wednesday, March 07, 2001 7:35 AM To: Php Mailing List Subject: [PHP] dates from db I am calling on a number of fields from my db one of which is a date. When the date displays it is in the following format -MM-DD 00:00:00 I Want it to only display the date and not the time like this -MM-DD Is it possible to remove the time when calling on it from the db Check the documentation for the database engine you're using. MySQL, for example, has a date_format() function that you can use in your query to specify what information you'd like displayed from a date/time field, and how you'd like it presented. --- Mark Roedel ([EMAIL PROTECTED]) || "There cannot be a crisis next week. Systems Programmer / WebMaster || My schedule is already full." LeTourneau University ||-- Henry Kissinger -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] dates
On Sun, Feb 18, 2001 at 04:40:08PM -0700, Julian Rockeu wrote: Anyone know how to use the PHP date functions to work out the difference between two timestamps? For example.. Figure out the number of seconds, minutes, hours, days, months and years between 5th October 2001 14:20:10 and 26th February 1998 109:54:10 This should be doable with http://php.net/mktime and http://php.net/date. But for such heavy calculations I prefer XEmacs calc-mode or the calendarr-mode. -Egon -- http://www.linuxtag.de/ http://php.net/books.php http://www.concert-band.de/ http://www.php-buch.de/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] dates
Yes I had a look at mktime() and date() and tried to think of an easy way to do it but couldn't... you can convert both dates to a UNIX timestamp (millseconds after whatever date) then do a subtraction... and then what? Easy to work out number of days from millseconds as a day's length is fixed but to go to months is harder as of course you need more information than just the actual elapsed time. Similar problam with mktime() as it's designed for actual dates, not differences between days. What is XEmacs calc- mode and calendar mode? I'm not all that familiar with Unix I'm afraid.. Thanks for your reply! Julian [EMAIL PROTECTED] wrote: On Sun, Feb 18, 2001 at 04:40:08PM -0700, Julian Rockeu wrote: Anyone know how to use the PHP date functions to work out the difference between two timestamps? For example.. Figure out the number of seconds, minutes, hours, days, months and years between 5th October 2001 14:20:10 and 26th February 1998 109:54:10 This should be doable with http://php.net/mktime and http://php.net/date. But for such heavy calculations I prefer XEmacs calc-mode or the calendarr-mode. -Egon -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] dates
On Sun, Feb 18, 2001 at 06:54:02PM -0700, Julian Rockey wrote: Yes I had a look at mktime() and date() and tried to think of an easy way to do it but couldn't... you can convert both dates to a UNIX timestamp (millseconds after whatever date) then do a subtraction... and then what? Easy to work out number of days from millseconds as a day's length is fixed but to go to months is harder as of course you need more information than just the actual elapsed time. Similar problam with mktime() as it's designed for actual dates, not differences between days. The Unix timestamp is in seconds after midnight January 1 1970. A approximatley calculation can be done with seconds. One minute has 60 seconds and 60 minutes are one hour. One day have 24 hours. But 24 hours times 7 days are not everytime a week and you should know a year has sometimes 365 days and sometimes 366 days. All calendar programs which are spret with GNU/Linux have some knowledge about the deviations. What is XEmacs calc- mode and calendar mode? I'm not all that familiar with Unix I'm afraid.. I think you can use XEmacs on all Windows operating systems. If I have time, I will install such a great editor on my Windows ME. Windows Notepad is such a pain. -Egon [EMAIL PROTECTED] wrote: On Sun, Feb 18, 2001 at 04:40:08PM -0700, Julian Rockeu wrote: Anyone know how to use the PHP date functions to work out the difference between two timestamps? For example.. Figure out the number of seconds, minutes, hours, days, months and years between 5th October 2001 14:20:10 and 26th February 1998 109:54:10 This should be doable with http://php.net/mktime and http://php.net/date. But for such heavy calculations I prefer XEmacs calc-mode or the calendarr-mode. -Egon -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- -- http://www.linuxtag.de/ http://php.net/books.php http://www.concert-band.de/ http://www.php-buch.de/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]