Re: [PHP] date time problem
On 10/6/2013 11:21 PM, Romain CIACCAFAVA wrote: An easier way to do that would be using the diff() method of a DateTime object on another. Regards Romain Ciaccafava Romain - you were so right. A little less calculating to be done and I got the result I wished. For anyone interested here's the function I'm using to determine how much time there is until a cookie expires. The cookie in question contains the expiration datetime that was used to create a paired cookie. function GetTimeLeft($applid) { if (isset($_COOKIE[$applid])) { if (isset($_COOKIE[$applid.expire])) { $curr_time = new datetime(); $cookietime = $_COOKIE[$applid.expire]; $exp_time = new datetime(); $exp_time-setTimeStamp($cookietime); $diff = $curr_time-diff($exp_time); $days = $diff-format(%d); $days = ($days 1) ? $days days: ($days == 1) ? $days day : ''; $hms = $diff-format(%h:%i:%s); return Time left: $days $hms; } else return '?'; } else return '0'; } -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] date time problem
I always hate dealing with date/time stuff in php - never get it even close until an hour or two goes by anyway I have this: // get two timestamp values $exp_time = $_COOKIE[$applid.expire]; $curr_time = time(); // get the difference $diff = $exp_time - $curr_time; // produce a display time of the diff $time_left = date(h:i:s,$diff); Currently the results are: exp_time is 06:55:07 curr_time is 06:12:03 the diff is 2584 All of these are correct. BUT time_left is 07:43:04 when it should be only 00:43:04. So - where is the hour value of '07' coming from?? And how do I get this right? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] date time problem
You should use gmdate() if you want to how many hours left to expire $time_left = gmdate(H:i:s,$diff); Best Regards Farzan Dalaee On Oct 7, 2013, at 1:49, Jim Giner jim.gi...@albanyhandball.com wrote: I always hate dealing with date/time stuff in php - never get it even close until an hour or two goes by anyway I have this: // get two timestamp values $exp_time = $_COOKIE[$applid.expire]; $curr_time = time(); // get the difference $diff = $exp_time - $curr_time; // produce a display time of the diff $time_left = date(h:i:s,$diff); Currently the results are: exp_time is 06:55:07 curr_time is 06:12:03 the diff is 2584 All of these are correct. BUT time_left is 07:43:04 when it should be only 00:43:04. So - where is the hour value of '07' coming from?? And how do I get this right? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] date time problem
On 10/6/2013 6:36 PM, Farzan Dalaee wrote: You should use gmdate() if you want to how many hours left to expire $time_left = gmdate(H:i:s,$diff); Best Regards Farzan Dalaee On Oct 7, 2013, at 1:49, Jim Giner jim.gi...@albanyhandball.com wrote: I always hate dealing with date/time stuff in php - never get it even close until an hour or two goes by anyway I have this: // get two timestamp values $exp_time = $_COOKIE[$applid.expire]; $curr_time = time(); // get the difference $diff = $exp_time - $curr_time; // produce a display time of the diff $time_left = date(h:i:s,$diff); Currently the results are: exp_time is 06:55:07 curr_time is 06:12:03 the diff is 2584 All of these are correct. BUT time_left is 07:43:04 when it should be only 00:43:04. So - where is the hour value of '07' coming from?? And how do I get this right? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Thanks for the quick response, but why do I want to show the time in GMT? However, I did try it, changing the 'time_left' calc to use gmdate. Now instead of a 7 for hours I have a 12. exp 07:34:52 curr 06:40:14 diff 3158 left is 12:52:38 The 52:38 is the correct value, but not the 12. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] date time problem
Try this please gmdate(H:i:s, $diff%86400) Best Regards Farzan Dalaee On Oct 7, 2013, at 2:12, Jim Giner jim.gi...@albanyhandball.com wrote: On 10/6/2013 6:36 PM, Farzan Dalaee wrote: You should use gmdate() if you want to how many hours left to expire $time_left = gmdate(H:i:s,$diff); Best Regards Farzan Dalaee On Oct 7, 2013, at 1:49, Jim Giner jim.gi...@albanyhandball.com wrote: I always hate dealing with date/time stuff in php - never get it even close until an hour or two goes by anyway I have this: // get two timestamp values $exp_time = $_COOKIE[$applid.expire]; $curr_time = time(); // get the difference $diff = $exp_time - $curr_time; // produce a display time of the diff $time_left = date(h:i:s,$diff); Currently the results are: exp_time is 06:55:07 curr_time is 06:12:03 the diff is 2584 All of these are correct. BUT time_left is 07:43:04 when it should be only 00:43:04. So - where is the hour value of '07' coming from?? And how do I get this right? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Thanks for the quick response, but why do I want to show the time in GMT? However, I did try it, changing the 'time_left' calc to use gmdate. Now instead of a 7 for hours I have a 12. exp 07:34:52 curr 06:40:14 diff 3158 left is 12:52:38 The 52:38 is the correct value, but not the 12. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] date time problem
On 10/6/2013 6:49 PM, Farzan Dalaee wrote: Try this please gmdate(H:i:s, $diff%86400) Best Regards Farzan Dalaee On Oct 7, 2013, at 2:12, Jim Giner jim.gi...@albanyhandball.com wrote: On 10/6/2013 6:36 PM, Farzan Dalaee wrote: You should use gmdate() if you want to how many hours left to expire $time_left = gmdate(H:i:s,$diff); Best Regards Farzan Dalaee On Oct 7, 2013, at 1:49, Jim Giner jim.gi...@albanyhandball.com wrote: I always hate dealing with date/time stuff in php - never get it even close until an hour or two goes by anyway I have this: // get two timestamp values $exp_time = $_COOKIE[$applid.expire]; $curr_time = time(); // get the difference $diff = $exp_time - $curr_time; // produce a display time of the diff $time_left = date(h:i:s,$diff); Currently the results are: exp_time is 06:55:07 curr_time is 06:12:03 the diff is 2584 All of these are correct. BUT time_left is 07:43:04 when it should be only 00:43:04. So - where is the hour value of '07' coming from?? And how do I get this right? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Thanks for the quick response, but why do I want to show the time in GMT? However, I did try it, changing the 'time_left' calc to use gmdate. Now instead of a 7 for hours I have a 12. exp 07:34:52 curr 06:40:14 diff 3158 left is 12:52:38 The 52:38 is the correct value, but not the 12. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Doesn't work either. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] date time problem
Its so freaky Best Regards Farzan Dalaee On Oct 7, 2013, at 2:29, Jim Giner jim.gi...@albanyhandball.com wrote: On 10/6/2013 6:49 PM, Farzan Dalaee wrote: Try this please gmdate(H:i:s, $diff%86400) Best Regards Farzan Dalaee On Oct 7, 2013, at 2:12, Jim Giner jim.gi...@albanyhandball.com wrote: On 10/6/2013 6:36 PM, Farzan Dalaee wrote: You should use gmdate() if you want to how many hours left to expire $time_left = gmdate(H:i:s,$diff); Best Regards Farzan Dalaee On Oct 7, 2013, at 1:49, Jim Giner jim.gi...@albanyhandball.com wrote: I always hate dealing with date/time stuff in php - never get it even close until an hour or two goes by anyway I have this: // get two timestamp values $exp_time = $_COOKIE[$applid.expire]; $curr_time = time(); // get the difference $diff = $exp_time - $curr_time; // produce a display time of the diff $time_left = date(h:i:s,$diff); Currently the results are: exp_time is 06:55:07 curr_time is 06:12:03 the diff is 2584 All of these are correct. BUT time_left is 07:43:04 when it should be only 00:43:04. So - where is the hour value of '07' coming from?? And how do I get this right? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Thanks for the quick response, but why do I want to show the time in GMT? However, I did try it, changing the 'time_left' calc to use gmdate. Now instead of a 7 for hours I have a 12. exp 07:34:52 curr 06:40:14 diff 3158 left is 12:52:38 The 52:38 is the correct value, but not the 12. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Doesn't work either. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] date time problem
This should help you out http://stackoverflow.com/questions/365191/how-to-get-time-difference-in-minutes-in-php On Oct 6, 2013 6:07 PM, Farzan Dalaee farzan.dal...@gmail.com wrote: Its so freaky Best Regards Farzan Dalaee On Oct 7, 2013, at 2:29, Jim Giner jim.gi...@albanyhandball.com wrote: On 10/6/2013 6:49 PM, Farzan Dalaee wrote: Try this please gmdate(H:i:s, $diff%86400) Best Regards Farzan Dalaee On Oct 7, 2013, at 2:12, Jim Giner jim.gi...@albanyhandball.com wrote: On 10/6/2013 6:36 PM, Farzan Dalaee wrote: You should use gmdate() if you want to how many hours left to expire $time_left = gmdate(H:i:s,$diff); Best Regards Farzan Dalaee On Oct 7, 2013, at 1:49, Jim Giner jim.gi...@albanyhandball.com wrote: I always hate dealing with date/time stuff in php - never get it even close until an hour or two goes by anyway I have this: // get two timestamp values $exp_time = $_COOKIE[$applid.expire]; $curr_time = time(); // get the difference $diff = $exp_time - $curr_time; // produce a display time of the diff $time_left = date(h:i:s,$diff); Currently the results are: exp_time is 06:55:07 curr_time is 06:12:03 the diff is 2584 All of these are correct. BUT time_left is 07:43:04 when it should be only 00:43:04. So - where is the hour value of '07' coming from?? And how do I get this right? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Thanks for the quick response, but why do I want to show the time in GMT? However, I did try it, changing the 'time_left' calc to use gmdate. Now instead of a 7 for hours I have a 12. exp 07:34:52 curr 06:40:14 diff 3158 left is 12:52:38 The 52:38 is the correct value, but not the 12. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Doesn't work either. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] date time problem
Jim, The date method takes in a timestamp (not seconds away). You have the seconds, you will need to manually convert those seconds to what you desire (minutes = seconds / 60), (hours = minutes / 60), etc.. Aziz On Sun, Oct 6, 2013 at 7:07 PM, Farzan Dalaee farzan.dal...@gmail.comwrote: Its so freaky Best Regards Farzan Dalaee On Oct 7, 2013, at 2:29, Jim Giner jim.gi...@albanyhandball.com wrote: On 10/6/2013 6:49 PM, Farzan Dalaee wrote: Try this please gmdate(H:i:s, $diff%86400) Best Regards Farzan Dalaee On Oct 7, 2013, at 2:12, Jim Giner jim.gi...@albanyhandball.com wrote: On 10/6/2013 6:36 PM, Farzan Dalaee wrote: You should use gmdate() if you want to how many hours left to expire $time_left = gmdate(H:i:s,$diff); Best Regards Farzan Dalaee On Oct 7, 2013, at 1:49, Jim Giner jim.gi...@albanyhandball.com wrote: I always hate dealing with date/time stuff in php - never get it even close until an hour or two goes by anyway I have this: // get two timestamp values $exp_time = $_COOKIE[$applid.expire]; $curr_time = time(); // get the difference $diff = $exp_time - $curr_time; // produce a display time of the diff $time_left = date(h:i:s,$diff); Currently the results are: exp_time is 06:55:07 curr_time is 06:12:03 the diff is 2584 All of these are correct. BUT time_left is 07:43:04 when it should be only 00:43:04. So - where is the hour value of '07' coming from?? And how do I get this right? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Thanks for the quick response, but why do I want to show the time in GMT? However, I did try it, changing the 'time_left' calc to use gmdate. Now instead of a 7 for hours I have a 12. exp 07:34:52 curr 06:40:14 diff 3158 left is 12:52:38 The 52:38 is the correct value, but not the 12. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Doesn't work either. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] date time problem
Look at my code. The inputs are all timestamps so date should work, no? My question why am i getting an hour value in this case? jg On Oct 6, 2013, at 7:14 PM, Aziz Saleh azizsa...@gmail.com wrote: Jim, The date method takes in a timestamp (not seconds away). You have the seconds, you will need to manually convert those seconds to what you desire (minutes = seconds / 60), (hours = minutes / 60), etc.. Aziz On Sun, Oct 6, 2013 at 7:07 PM, Farzan Dalaee farzan.dal...@gmail.com wrote: Its so freaky Best Regards Farzan Dalaee On Oct 7, 2013, at 2:29, Jim Giner jim.gi...@albanyhandball.com wrote: On 10/6/2013 6:49 PM, Farzan Dalaee wrote: Try this please gmdate(H:i:s, $diff%86400) Best Regards Farzan Dalaee On Oct 7, 2013, at 2:12, Jim Giner jim.gi...@albanyhandball.com wrote: On 10/6/2013 6:36 PM, Farzan Dalaee wrote: You should use gmdate() if you want to how many hours left to expire $time_left = gmdate(H:i:s,$diff); Best Regards Farzan Dalaee On Oct 7, 2013, at 1:49, Jim Giner jim.gi...@albanyhandball.com wrote: I always hate dealing with date/time stuff in php - never get it even close until an hour or two goes by anyway I have this: // get two timestamp values $exp_time = $_COOKIE[$applid.expire]; $curr_time = time(); // get the difference $diff = $exp_time - $curr_time; // produce a display time of the diff $time_left = date(h:i:s,$diff); Currently the results are: exp_time is 06:55:07 curr_time is 06:12:03 the diff is 2584 All of these are correct. BUT time_left is 07:43:04 when it should be only 00:43:04. So - where is the hour value of '07' coming from?? And how do I get this right? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Thanks for the quick response, but why do I want to show the time in GMT? However, I did try it, changing the 'time_left' calc to use gmdate. Now instead of a 7 for hours I have a 12. exp 07:34:52 curr 06:40:14 diff 3158 left is 12:52:38 The 52:38 is the correct value, but not the 12. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Doesn't work either. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] date time problem
The resulting subtraction is not a valid timestamp, but rather the difference between the two timestamps in seconds . The resulting diff can be 1 if the timestamps are 1 seconds apart. The linkhttp://stackoverflow.com/questions/365191/how-to-get-time-difference-in-minutes-in-phpJonathan sent out contains functions that does the division for you with results. Another link you can check out: http://stackoverflow.com/a/9143387/1935500 On Sun, Oct 6, 2013 at 7:29 PM, Jim Giner jim.gi...@albanyhandball.comwrote: Look at my code. The inputs are all timestamps so date should work, no? My question why am i getting an hour value in this case? jg On Oct 6, 2013, at 7:14 PM, Aziz Saleh azizsa...@gmail.com wrote: Jim, The date method takes in a timestamp (not seconds away). You have the seconds, you will need to manually convert those seconds to what you desire (minutes = seconds / 60), (hours = minutes / 60), etc.. Aziz On Sun, Oct 6, 2013 at 7:07 PM, Farzan Dalaee farzan.dal...@gmail.comwrote: Its so freaky Best Regards Farzan Dalaee On Oct 7, 2013, at 2:29, Jim Giner jim.gi...@albanyhandball.com wrote: On 10/6/2013 6:49 PM, Farzan Dalaee wrote: Try this please gmdate(H:i:s, $diff%86400) Best Regards Farzan Dalaee On Oct 7, 2013, at 2:12, Jim Giner jim.gi...@albanyhandball.com wrote: On 10/6/2013 6:36 PM, Farzan Dalaee wrote: You should use gmdate() if you want to how many hours left to expire $time_left = gmdate(H:i:s,$diff); Best Regards Farzan Dalaee On Oct 7, 2013, at 1:49, Jim Giner jim.gi...@albanyhandball.com wrote: I always hate dealing with date/time stuff in php - never get it even close until an hour or two goes by anyway I have this: // get two timestamp values $exp_time = $_COOKIE[$applid.expire]; $curr_time = time(); // get the difference $diff = $exp_time - $curr_time; // produce a display time of the diff $time_left = date(h:i:s,$diff); Currently the results are: exp_time is 06:55:07 curr_time is 06:12:03 the diff is 2584 All of these are correct. BUT time_left is 07:43:04 when it should be only 00:43:04. So - where is the hour value of '07' coming from?? And how do I get this right? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Thanks for the quick response, but why do I want to show the time in GMT? However, I did try it, changing the 'time_left' calc to use gmdate. Now instead of a 7 for hours I have a 12. exp 07:34:52 curr 06:40:14 diff 3158 left is 12:52:38 The 52:38 is the correct value, but not the 12. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Doesn't work either. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] date time problem
On Sun, 2013-10-06 at 19:14 -0400, Aziz Saleh wrote: Jim, The date method takes in a timestamp (not seconds away). You have the seconds, you will need to manually convert those seconds to what you desire (minutes = seconds / 60), (hours = minutes / 60), etc.. Aziz On Sun, Oct 6, 2013 at 7:07 PM, Farzan Dalaee farzan.dal...@gmail.comwrote: Its so freaky Best Regards Farzan Dalaee On Oct 7, 2013, at 2:29, Jim Giner jim.gi...@albanyhandball.com wrote: On 10/6/2013 6:49 PM, Farzan Dalaee wrote: Try this please gmdate(H:i:s, $diff%86400) Best Regards Farzan Dalaee On Oct 7, 2013, at 2:12, Jim Giner jim.gi...@albanyhandball.com wrote: On 10/6/2013 6:36 PM, Farzan Dalaee wrote: You should use gmdate() if you want to how many hours left to expire $time_left = gmdate(H:i:s,$diff); Best Regards Farzan Dalaee On Oct 7, 2013, at 1:49, Jim Giner jim.gi...@albanyhandball.com wrote: I always hate dealing with date/time stuff in php - never get it even close until an hour or two goes by anyway I have this: // get two timestamp values $exp_time = $_COOKIE[$applid.expire]; $curr_time = time(); // get the difference $diff = $exp_time - $curr_time; // produce a display time of the diff $time_left = date(h:i:s,$diff); Currently the results are: exp_time is 06:55:07 curr_time is 06:12:03 the diff is 2584 All of these are correct. BUT time_left is 07:43:04 when it should be only 00:43:04. So - where is the hour value of '07' coming from?? And how do I get this right? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Thanks for the quick response, but why do I want to show the time in GMT? However, I did try it, changing the 'time_left' calc to use gmdate. Now instead of a 7 for hours I have a 12. exp 07:34:52 curr 06:40:14 diff 3158 left is 12:52:38 The 52:38 is the correct value, but not the 12. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Doesn't work either. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Aziz, please try not to top post :) It's true that the date() function takes in a timestamp as its argument, but a timestamp is a number representing the number of seconds since 00:00:00 1st January 1970, so passing in a very small number of seconds is perfectly valid. The only thing that would account for the 7 hours difference is the time zone, which would also be part of the timestamp. http://en.wikipedia.org/wiki/Unix_time gives more details. Thanks, Ash http://www.ashleysheridan.co.uk
Re: [PHP] date time problem
On 10/6/2013 7:40 PM, Aziz Saleh wrote: The resulting subtraction is not a valid timestamp, but rather the difference between the two timestamps in seconds . The resulting diff can be 1 if the timestamps are 1 seconds apart. The linkhttp://stackoverflow.com/questions/365191/how-to-get-time-difference-in-minutes-in-phpJonathan sent out contains functions that does the division for you with results. Another link you can check out: http://stackoverflow.com/a/9143387/1935500 On Sun, Oct 6, 2013 at 7:29 PM, Jim Giner jim.gi...@albanyhandball.comwrote: Look at my code. The inputs are all timestamps so date should work, no? My question why am i getting an hour value in this case? jg On Oct 6, 2013, at 7:14 PM, Aziz Saleh azizsa...@gmail.com wrote: Jim, The date method takes in a timestamp (not seconds away). You have the seconds, you will need to manually convert those seconds to what you desire (minutes = seconds / 60), (hours = minutes / 60), etc.. Aziz On Sun, Oct 6, 2013 at 7:07 PM, Farzan Dalaee farzan.dal...@gmail.comwrote: Its so freaky Best Regards Farzan Dalaee On Oct 7, 2013, at 2:29, Jim Giner jim.gi...@albanyhandball.com wrote: On 10/6/2013 6:49 PM, Farzan Dalaee wrote: Try this please gmdate(H:i:s, $diff%86400) Best Regards Farzan Dalaee On Oct 7, 2013, at 2:12, Jim Giner jim.gi...@albanyhandball.com wrote: On 10/6/2013 6:36 PM, Farzan Dalaee wrote: You should use gmdate() if you want to how many hours left to expire $time_left = gmdate(H:i:s,$diff); Best Regards Farzan Dalaee On Oct 7, 2013, at 1:49, Jim Giner jim.gi...@albanyhandball.com wrote: I always hate dealing with date/time stuff in php - never get it even close until an hour or two goes by anyway I have this: // get two timestamp values $exp_time = $_COOKIE[$applid.expire]; $curr_time = time(); // get the difference $diff = $exp_time - $curr_time; // produce a display time of the diff $time_left = date(h:i:s,$diff); Currently the results are: exp_time is 06:55:07 curr_time is 06:12:03 the diff is 2584 All of these are correct. BUT time_left is 07:43:04 when it should be only 00:43:04. So - where is the hour value of '07' coming from?? And how do I get this right? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Thanks for the quick response, but why do I want to show the time in GMT? However, I did try it, changing the 'time_left' calc to use gmdate. Now instead of a 7 for hours I have a 12. exp 07:34:52 curr 06:40:14 diff 3158 left is 12:52:38 The 52:38 is the correct value, but not the 12. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Doesn't work either. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Good Point! I never looked at it that way. I guess the Date function can't be relied on in that case. So now I'll have to calculate my time in a mathematical way instead of letting Date translate it for me. Thanks! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] date time problem
On 10/6/2013 7:55 PM, Ashley Sheridan wrote: On Sun, 2013-10-06 at 19:14 -0400, Aziz Saleh wrote: Jim, The date method takes in a timestamp (not seconds away). You have the seconds, you will need to manually convert those seconds to what you desire (minutes = seconds / 60), (hours = minutes / 60), etc.. Aziz On Sun, Oct 6, 2013 at 7:07 PM, Farzan Dalaee farzan.dal...@gmail.comwrote: Its so freaky Best Regards Farzan Dalaee On Oct 7, 2013, at 2:29, Jim Giner jim.gi...@albanyhandball.com wrote: On 10/6/2013 6:49 PM, Farzan Dalaee wrote: Try this please gmdate(H:i:s, $diff%86400) Best Regards Farzan Dalaee On Oct 7, 2013, at 2:12, Jim Giner jim.gi...@albanyhandball.com wrote: On 10/6/2013 6:36 PM, Farzan Dalaee wrote: You should use gmdate() if you want to how many hours left to expire $time_left = gmdate(H:i:s,$diff); Best Regards Farzan Dalaee On Oct 7, 2013, at 1:49, Jim Giner jim.gi...@albanyhandball.com wrote: I always hate dealing with date/time stuff in php - never get it even close until an hour or two goes by anyway I have this: // get two timestamp values $exp_time = $_COOKIE[$applid.expire]; $curr_time = time(); // get the difference $diff = $exp_time - $curr_time; // produce a display time of the diff $time_left = date(h:i:s,$diff); Currently the results are: exp_time is 06:55:07 curr_time is 06:12:03 the diff is 2584 All of these are correct. BUT time_left is 07:43:04 when it should be only 00:43:04. So - where is the hour value of '07' coming from?? And how do I get this right? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Thanks for the quick response, but why do I want to show the time in GMT? However, I did try it, changing the 'time_left' calc to use gmdate. Now instead of a 7 for hours I have a 12. exp 07:34:52 curr 06:40:14 diff 3158 left is 12:52:38 The 52:38 is the correct value, but not the 12. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Doesn't work either. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Aziz, please try not to top post :) It's true that the date() function takes in a timestamp as its argument, but a timestamp is a number representing the number of seconds since 00:00:00 1st January 1970, so passing in a very small number of seconds is perfectly valid. The only thing that would account for the 7 hours difference is the time zone, which would also be part of the timestamp. http://en.wikipedia.org/wiki/Unix_time gives more details. Thanks, Ash http://www.ashleysheridan.co.uk Thanks Ash, but the previous (top) post explained my dilemma just as you have done here. My attempt to use a function to avoid doing the math has now been resolved. Guess I'll have to do it the old-fashioned way. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] date time problem
An easier way to do that would be using the diff() method of a DateTime object on another. Regards Romain Ciaccafava Le 7 oct. 2013 à 03:10, Jim Giner jim.gi...@albanyhandball.com a écrit : On 10/6/2013 7:55 PM, Ashley Sheridan wrote: On Sun, 2013-10-06 at 19:14 -0400, Aziz Saleh wrote: Jim, The date method takes in a timestamp (not seconds away). You have the seconds, you will need to manually convert those seconds to what you desire (minutes = seconds / 60), (hours = minutes / 60), etc.. Aziz On Sun, Oct 6, 2013 at 7:07 PM, Farzan Dalaee farzan.dal...@gmail.comwrote: Its so freaky Best Regards Farzan Dalaee On Oct 7, 2013, at 2:29, Jim Giner jim.gi...@albanyhandball.com wrote: On 10/6/2013 6:49 PM, Farzan Dalaee wrote: Try this please gmdate(H:i:s, $diff%86400) Best Regards Farzan Dalaee On Oct 7, 2013, at 2:12, Jim Giner jim.gi...@albanyhandball.com wrote: On 10/6/2013 6:36 PM, Farzan Dalaee wrote: You should use gmdate() if you want to how many hours left to expire $time_left = gmdate(H:i:s,$diff); Best Regards Farzan Dalaee On Oct 7, 2013, at 1:49, Jim Giner jim.gi...@albanyhandball.com wrote: I always hate dealing with date/time stuff in php - never get it even close until an hour or two goes by anyway I have this: // get two timestamp values $exp_time = $_COOKIE[$applid.expire]; $curr_time = time(); // get the difference $diff = $exp_time - $curr_time; // produce a display time of the diff $time_left = date(h:i:s,$diff); Currently the results are: exp_time is 06:55:07 curr_time is 06:12:03 the diff is 2584 All of these are correct. BUT time_left is 07:43:04 when it should be only 00:43:04. So - where is the hour value of '07' coming from?? And how do I get this right? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Thanks for the quick response, but why do I want to show the time in GMT? However, I did try it, changing the 'time_left' calc to use gmdate. Now instead of a 7 for hours I have a 12. exp 07:34:52 curr 06:40:14 diff 3158 left is 12:52:38 The 52:38 is the correct value, but not the 12. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Doesn't work either. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Aziz, please try not to top post :) It's true that the date() function takes in a timestamp as its argument, but a timestamp is a number representing the number of seconds since 00:00:00 1st January 1970, so passing in a very small number of seconds is perfectly valid. The only thing that would account for the 7 hours difference is the time zone, which would also be part of the timestamp. http://en.wikipedia.org/wiki/Unix_time gives more details. Thanks, Ash http://www.ashleysheridan.co.uk Thanks Ash, but the previous (top) post explained my dilemma just as you have done here. My attempt to use a function to avoid doing the math has now been resolved. Guess I'll have to do it the old-fashioned way. -- 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] date time late or lagging
hi all, $dateNow = date('Y-m-d H:i:s'); echo pstrong.$dateNow ./strong/p; can some see why the date time is lagging or late by 30 minutes from the server time even when server time are correct
Re: [PHP] date time late or lagging RESOLVED
On Tue, Apr 28, 2009 at 3:45 PM, Andrew Williams andrew4willi...@gmail.comwrote: hi all, $dateNow = date('Y-m-d H:i:s'); echo pstrong.$dateNow ./strong/p; can some see why the date time is lagging or late by 30 minutes from the server time even when server time are correct -- Best Wishes Andrew Williams www.NPinvestor.com
Re: [PHP] Date/time format?
2007. 03. 30, péntek keltezéssel 14.00-kor Jason Pruim ezt írta: On Mar 29, 2007, at 4:52 PM, Zoltán Németh wrote: snip (I assume you want this calculation within one given day) you could read all rows into an array like $timeinfo = array(); $sql = SELECT minute, sequence FROM table WHERE day='$day'; $result = mysql_query($result); while ($row = mysql_fetch_assoc($result)) { $timeinfo[$row['sequence'] = $row['minute']; } and then calculate and echo the difference between any element of the array: $diff0_1 = $timeinfo[1] - $timeinfo[0]; $timeinfo[$row['sequence'] = $row['minute']; --- is the [ between $timeinfo and $row a typo? or is there supposed to be a closing ] somewhere? yeah it should be closed, sorry for the typo. this way: $timeinfo[$row['sequence']] = $row['minute']; greets Zoltán Németh When I add a closing ] to it as such: $timeinfo[$row['sequence'] = $row['minute']]; I get this error when I try and open the page: [Fri Mar 30 13:55:36 2007] [error] PHP Notice: Undefined index: minute in /Volumes/RAIDer/webserver/Documents/tests/oatstest/ oatstime.php on line 15 [Fri Mar 30 13:55:36 2007] [error] PHP Notice: Undefined index: in /Volumes/RAIDer/webserver/Documents/tests/oatstest/oatstime.php on line 15 [Fri Mar 30 13:55:36 2007] [error] PHP Notice: Undefined offset: 1 in /Volumes/RAIDer/webserver/Documents/tests/oatstest/oatstime.php on line 18 [Fri Mar 30 13:55:36 2007] [error] PHP Notice: Undefined offset: 0 in /Volumes/RAIDer/webserver/Documents/tests/oatstest/oatstime.php on line 18 Line 15 is this line: $timeinfo[$row['sequence'] = $row['minute']]; and line 18 has: $diff0_1 = $timeinfo[1] - $timeinfo[0]; What I am trying to do is subtract $timeinfo[1] from $timeinfo[0] and then display the difference. When I echo $timeinfo it just says array so my thinking is that the errors are caused by the array not being populated properly based on the extra [ or a missing ]. Am I at least on the right track? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Date/time format?
On Mar 29, 2007, at 6:16 PM, Jim Lucas wrote: you stated in a different email that there are 6 possible values/ settings for the sequence col. what are they, and what do they mean? One person asked about missed punches. What happens if someone forgets to clock out? Is an entry made for the person for the appropriate day/minutes/sequence ??? I can see a way to do what you are asking, but I need these questions answered first. Okay, here's what I have figured out about how the original programmer did it. Employees are given the option of using a clock in/clock out link on the web page or entering the hours manually. Most of the employees just sign in/out at the end of the day. The sequence number is used to keep it in order so that it can do the math based on the right day. sequence 0 is the first sign in, sequence 1 is the first sign out, sequence 2 is the second sign in, sequence 3 is the second sign out etc. etc.. Basically if an employee works from 8:00 AM until 4:30 PM with a half hour lunch the database would look something like this: Sequence 0 480 (8 AM) IN Sequence 1 720 (12 noon) OUT Sequence 2 750 (12:30) IN Sequence 3 990 (4:30) OUT Or if they work until 7 PM with a break for lunch and supper it would look like: Sequence 0 480 (8 AM) IN Sequence 1 720 (12 noon) OUT Sequence 2 750 (12:30) IN Sequence 3 990 (4:30) OUT Sequence 4 1020 (5PM) IN Sequence 5 1140 (7PM) OUT The idea being if you sort by employee, day, and then sequence you can do the math by subtracting sequence 0 from sequence 1, sequence 2 from sequence 3 etc. etc. When I started looking at this originally, I was just looking at adding a feature to it, but now I'm thinking that since I've learned a fair amount about working with databases, I may try and write my own as a side project to learn even more :) I will try the suggestions that were given and any new ones that come in and see what works best, and when I do that I'll post the results back here for posterity. Thanks everyone for your help! It's because of people like you that I have been able to come as far as I have in this world. -- Jason Pruim [EMAIL PROTECTED] Production Technology Manager MQC Specialist (2005 certified) 3251 132nd Ave Holland MI 49424 616.399.2355 www.raoset.com “Give me your tired, your poor, Your huddled masses yearning to breathe free, The wretched refuse of your teeming shore. Send these, the homeless tempest-tost to me, I lift my lamp beside the golden door!” From “The New Colossus,” by Emma Lazarus smime.p7s Description: S/MIME cryptographic signature
Re: [PHP] Date/time format?
On Mar 29, 2007, at 4:52 PM, Zoltán Németh wrote: snip (I assume you want this calculation within one given day) you could read all rows into an array like $timeinfo = array(); $sql = SELECT minute, sequence FROM table WHERE day='$day'; $result = mysql_query($result); while ($row = mysql_fetch_assoc($result)) { $timeinfo[$row['sequence'] = $row['minute']; } and then calculate and echo the difference between any element of the array: $diff0_1 = $timeinfo[1] - $timeinfo[0]; $timeinfo[$row['sequence'] = $row['minute']; --- is the [ between $timeinfo and $row a typo? or is there supposed to be a closing ] somewhere? When I add a closing ] to it as such: $timeinfo[$row['sequence'] = $row['minute']]; I get this error when I try and open the page: [Fri Mar 30 13:55:36 2007] [error] PHP Notice: Undefined index: minute in /Volumes/RAIDer/webserver/Documents/tests/oatstest/ oatstime.php on line 15 [Fri Mar 30 13:55:36 2007] [error] PHP Notice: Undefined index: in /Volumes/RAIDer/webserver/Documents/tests/oatstest/oatstime.php on line 15 [Fri Mar 30 13:55:36 2007] [error] PHP Notice: Undefined offset: 1 in /Volumes/RAIDer/webserver/Documents/tests/oatstest/oatstime.php on line 18 [Fri Mar 30 13:55:36 2007] [error] PHP Notice: Undefined offset: 0 in /Volumes/RAIDer/webserver/Documents/tests/oatstest/oatstime.php on line 18 Line 15 is this line: $timeinfo[$row['sequence'] = $row['minute']]; and line 18 has: $diff0_1 = $timeinfo[1] - $timeinfo[0]; What I am trying to do is subtract $timeinfo[1] from $timeinfo[0] and then display the difference. When I echo $timeinfo it just says array so my thinking is that the errors are caused by the array not being populated properly based on the extra [ or a missing ]. Am I at least on the right track? -- Jason Pruim [EMAIL PROTECTED] Production Technology Manager MQC Specialist (2005 certified) 3251 132nd Ave Holland MI 49424 616.399.2355 www.raoset.com We hold these truths to be self-evident. That all men are created equal, that they are endowed by their creator with certain unalienable rights, (and) that among these are Life, Liberty, and the pursuit of Happiness. smime.p7s Description: S/MIME cryptographic signature
Re: [PHP] Date/time format?
Thanks everyone for your suggestions, it turns out it was a unix time stamp and I can get it to parse out a normal date now. Now... on to the harder part What I am trying to do is learn... This is kind of just a pet project for me to figure out how I can do it. here is how the database is laid out: +---++-+- +--+ | user | day| job_name | minutes | sequence | +---++-+- +--+ | root | 1172466000 | Production technology Manager | 480 |0 | | root | 1172466000 | Production technology Manager | 720 |1 | | root | 1172466000 | Production technology Manager | 750 |2 | | root | 1172466000 | Production technology Manager | 990 |3 | the minutes column is the number of minutes that have passed since midnight. the sequence number refers to the sequence that the times were entered, meaning that 480 minutes after midnight came before 720 minutes, which was before 750 minutes which was before 990 minutes. What I need to do, is be able to calculate the time between 0 1, 2 3, 4 5 (there is a total of 6 sequences that could be in here) here is now the math would like on that particular entry: (480-720) + (750-990)=480/60=8 hours. This is a timecard program that I'm trying to write a report for to show the time for the entire month instead of it's default for the week. You can see what I have tried live at: raoset.com/tests/ oatstest/oats.shtml the code that I need help with is the math. I have looked but I just can't find a clear way to get the info from mysql, into an array in php to do the math? Maybe I've been looking at it to long and so I'm missing easy stuff? I have tried this code: $querytime = mysql_query(select sum(minutes) as t1, sum(sequence) as t2 from oats_time); while($row = mysql_fetch_array($querytime)){ $fulltotal=$row['t1']+$row['t2']; echo($fulltotal); } but that didn't work the way I wanted it to. Anyway... Post is long enough to start, so let me know if there is other info you need. Thanks in advance! -- Jason Pruim [EMAIL PROTECTED] Production Technology Manager MQC Specialist (2005 certified) 3251 132nd Ave Holland MI 49424 616.399.2355 www.raoset.com America will never be destroyed from the outside. If we falter and lose our freedoms, it will be because we destroyed ourselves. -Abraham Lincoln smime.p7s Description: S/MIME cryptographic signature
Re: [PHP] Date/time format?
2007. 03. 29, csütörtök keltezéssel 16.38-kor Jason Pruim ezt írta: Thanks everyone for your suggestions, it turns out it was a unix time stamp and I can get it to parse out a normal date now. Now... on to the harder part What I am trying to do is learn... This is kind of just a pet project for me to figure out how I can do it. here is how the database is laid out: +---++-+- +--+ | user | day| job_name | minutes | sequence | +---++-+- +--+ | root | 1172466000 | Production technology Manager | 480 |0 | | root | 1172466000 | Production technology Manager | 720 |1 | | root | 1172466000 | Production technology Manager | 750 |2 | | root | 1172466000 | Production technology Manager | 990 |3 | the minutes column is the number of minutes that have passed since midnight. the sequence number refers to the sequence that the times were entered, meaning that 480 minutes after midnight came before 720 minutes, which was before 750 minutes which was before 990 minutes. What I need to do, is be able to calculate the time between 0 1, 2 3, 4 5 (there is a total of 6 sequences that could be in here) here is now the math would like on that particular entry: (480-720) + (750-990)=480/60=8 hours. This is a timecard program that I'm trying to write a report for to show the time for the entire month instead of it's default for the week. You can see what I have tried live at: raoset.com/tests/ oatstest/oats.shtml the code that I need help with is the math. I have looked but I just can't find a clear way to get the info from mysql, into an array in php to do the math? Maybe I've been looking at it to long and so I'm missing easy stuff? I have tried this code: $querytime = mysql_query(select sum(minutes) as t1, sum(sequence) as t2 from oats_time); while($row = mysql_fetch_array($querytime)){ $fulltotal=$row['t1']+$row['t2']; echo($fulltotal); } but that didn't work the way I wanted it to. Anyway... Post is long enough to start, so let me know if there is other info you need. (I assume you want this calculation within one given day) you could read all rows into an array like $timeinfo = array(); $sql = SELECT minute, sequence FROM table WHERE day='$day'; $result = mysql_query($result); while ($row = mysql_fetch_assoc($result)) { $timeinfo[$row['sequence'] = $row['minute']; } and then calculate and echo the difference between any element of the array: $diff0_1 = $timeinfo[1] - $timeinfo[0]; greets Zoltán Németh Thanks in advance! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Date/time format?
Jason Pruim wrote: Thanks everyone for your suggestions, it turns out it was a unix time stamp and I can get it to parse out a normal date now. Now... on to the harder part What I am trying to do is learn... This is kind of just a pet project for me to figure out how I can do it. here is how the database is laid out: +---++-+-+--+ | user | day| job_name | minutes | sequence | +---++-+-+--+ | root | 1172466000 | Production technology Manager | 480 |0 | | root | 1172466000 | Production technology Manager | 720 |1 | | root | 1172466000 | Production technology Manager | 750 |2 | | root | 1172466000 | Production technology Manager | 990 |3 | Your table has different types of records in it -- clock in, and clock out. You are using order to assume which record is a start time and which is an end time. This is very vague. Also what happens if you are working late past midnight or someone forgets to clock out? I think a better approach would be to have a clock in field (timestamp) and a clock out field (another timestamp). That will simplify things considerably. You can then calculate your time totals with math on each record instead of across records: select (clock_out - clock_in)/3600 AS hours_worked from table ... Or: select sum((...)) etc. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Date/time format?
Roberto Mansfield wrote: Jason Pruim wrote: Thanks everyone for your suggestions, it turns out it was a unix time stamp and I can get it to parse out a normal date now. Now... on to the harder part What I am trying to do is learn... This is kind of just a pet project for me to figure out how I can do it. here is how the database is laid out: +---++-+-+--+ | user | day| job_name | minutes | sequence | +---++-+-+--+ | root | 1172466000 | Production technology Manager | 480 |0 | | root | 1172466000 | Production technology Manager | 720 |1 | | root | 1172466000 | Production technology Manager | 750 |2 | | root | 1172466000 | Production technology Manager | 990 |3 | Your table has different types of records in it -- clock in, and clock out. You are using order to assume which record is a start time and which is an end time. This is very vague. Also what happens if you are working late past midnight or someone forgets to clock out? I think a better approach would be to have a clock in field (timestamp) and a clock out field (another timestamp). That will simplify things considerably. You can then calculate your time totals with math on each record instead of across records: select (clock_out - clock_in)/3600 AS hours_worked from table ... Or: select sum((...)) etc. He doesn't have the option of changing this, it is a pre existing system. He is just trying to add a feature. -- Enjoy, Jim Lucas Different eyes see different things. Different hearts beat on different strings. But there are times for you and me when all such things agree. - Rush -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Date/time format?
Jason Pruim wrote: Hi Everyone, First off, I'm using PHP 5.2.0 and apache 1.3.33 I am trying to figure out what format a string is in in a database. It's a timecard system that I have found on-line and I am attempting to figure out how to write a script that would give me everyones timecard for the month on one screen I can print out for accounting to use. Below is an example of one of the lines in the database, What I'm really interested in is how it represents the day. user dayjob_name minutes sequence root 1171774800 Production technology Manager 990 3 I have not been able to find ANY info about that format, other then other people using it in blogs. I think I can figure out the rest as I go if I know how to decode the day. Any help or pointers to the M would be GREATLY appreciated! :) -- Jason Pruim [EMAIL PROTECTED] Production Technology Manager MQC Specialist (2005 certified) 3251 132nd Ave Holland MI 49424 616.399.2355 www.raoset.com “Give me your tired, your poor, Your huddled masses yearning to breathe free, The wretched refuse of your teeming shore. Send these, the homeless tempest-tost to me, I lift my lamp beside the golden door!” From “The New Colossus,” by Emma Lazarus you stated in a different email that there are 6 possible values/settings for the sequence col. what are they, and what do they mean? One person asked about missed punches. What happens if someone forgets to clock out? Is an entry made for the person for the appropriate day/minutes/sequence ??? I can see a way to do what you are asking, but I need these questions answered first. -- Enjoy, Jim Lucas Different eyes see different things. Different hearts beat on different strings. But there are times for you and me when all such things agree. - Rush -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Date/time format?
Hi Everyone, First off, I'm using PHP 5.2.0 and apache 1.3.33 I am trying to figure out what format a string is in in a database. It's a timecard system that I have found on-line and I am attempting to figure out how to write a script that would give me everyones timecard for the month on one screen I can print out for accounting to use. Below is an example of one of the lines in the database, What I'm really interested in is how it represents the day. user dayjob_name minutes sequence root 1171774800 Production technology Manager 990 3 I have not been able to find ANY info about that format, other then other people using it in blogs. I think I can figure out the rest as I go if I know how to decode the day. Any help or pointers to the M would be GREATLY appreciated! :) -- Jason Pruim [EMAIL PROTECTED] Production Technology Manager MQC Specialist (2005 certified) 3251 132nd Ave Holland MI 49424 616.399.2355 www.raoset.com “Give me your tired, your poor, Your huddled masses yearning to breathe free, The wretched refuse of your teeming shore. Send these, the homeless tempest-tost to me, I lift my lamp beside the golden door!” From “The New Colossus,” by Emma Lazarus smime.p7s Description: S/MIME cryptographic signature
Re: [PHP] Date/time format?
Jason Pruim wrote: Hi Everyone, First off, I'm using PHP 5.2.0 and apache 1.3.33 I am trying to figure out what format a string is in in a database. It's a timecard system that I have found on-line and I am attempting to figure out how to write a script that would give me everyones timecard for the month on one screen I can print out for accounting to use. Below is an example of one of the lines in the database, What I'm really interested in is how it represents the day. user dayjob_name minutes sequence root 1171774800 Production technology Manager 990 3 Could it be Feb 18, 2007 ?? If so, then that is just the unix timestamp. echo date('r', 1171774800); more data functions at: http://www.php.net/date -B I have not been able to find ANY info about that format, other then other people using it in blogs. I think I can figure out the rest as I go if I know how to decode the day. Any help or pointers to the M would be GREATLY appreciated! :) -- Jason Pruim [EMAIL PROTECTED] Production Technology Manager MQC Specialist (2005 certified) 3251 132nd Ave Holland MI 49424 616.399.2355 www.raoset.com “Give me your tired, your poor, Your huddled masses yearning to breathe free, The wretched refuse of your teeming shore. Send these, the homeless tempest-tost to me, I lift my lamp beside the golden door!” From “The New Colossus,” by Emma Lazarus -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Date/time format?
Jason Pruim wrote: Hi Everyone, First off, I'm using PHP 5.2.0 and apache 1.3.33 I am trying to figure out what format a string is in in a database. It's a timecard system that I have found on-line and I am attempting to figure out how to write a script that would give me everyones timecard for the month on one screen I can print out for accounting to use. Below is an example of one of the lines in the database, What I'm really interested in is how it represents the day. user dayjob_name minutes sequence root 1171774800 Production technology Manager 990 3 Looks like epoch time. Use date(Y-m-d,$epochtime); to get a standard date string out of it. www.php.net/date/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Date/time format?
2007. 03. 28, szerda keltezéssel 15.35-kor Jason Pruim ezt írta: Hi Everyone, First off, I'm using PHP 5.2.0 and apache 1.3.33 I am trying to figure out what format a string is in in a database. It's a timecard system that I have found on-line and I am attempting to figure out how to write a script that would give me everyones timecard for the month on one screen I can print out for accounting to use. Below is an example of one of the lines in the database, What I'm really interested in is how it represents the day. user dayjob_name minutes sequence root 1171774800 Production technology Manager 990 3 I have not been able to find ANY info about that format, other then other people using it in blogs. I think I can figure out the rest as I go if I know how to decode the day. Any help or pointers to the M would be GREATLY appreciated! :) what does strtotime return for that string? greets Zoltán Németh -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Date/time format?
Zoltán Németh wrote: 2007. 03. 28, szerda keltezéssel 15.35-kor Jason Pruim ezt írta: Hi Everyone, First off, I'm using PHP 5.2.0 and apache 1.3.33 I am trying to figure out what format a string is in in a database. It's a timecard system that I have found on-line and I am attempting to figure out how to write a script that would give me everyones timecard for the month on one screen I can print out for accounting to use. Below is an example of one of the lines in the database, What I'm really interested in is how it represents the day. user dayjob_name minutes sequence root 1171774800 Production technology Manager 990 3 I have not been able to find ANY info about that format, other then other people using it in blogs. I think I can figure out the rest as I go if I know how to decode the day. Any help or pointers to the M would be GREATLY appreciated! :) what does strtotime return for that string? It's already a time, strtotime should return FALSE. It probably can't parse that string to a time. Travis D -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Date/time format?
Jason wrote: Hi Everyone, First off, I'm using PHP 5.2.0 and apache 1.3.33 I am trying to figure out what format a string is in in a database. It's a timecard system that I have found on-line and I am attempting to figure out how to write a script that would give me everyones timecard for the month on one screen I can print out for accounting to use. Below is an example of one of the lines in the database, What I'm really interested in is how it represents the day. user dayjob_name minutes sequence root 1171774800 Production technology Manager 990 3 I have not been able to find ANY info about that format, other then other people using it in blogs. I think I can figure out the rest as I go if I know how to decode the day. Any help or pointers to the M would be GREATLY appreciated! :) That is a UNIX timestamp, which is the type of date that the php date() function takes as a 2nd parameter. So for example, ?php echo date(m/d/Y, $row['day']) // Output: 02/18/2007 ? You can also format it in the query like so: mysql SELECT FROM_UNIXTIME(day) AS theDate FROM myTable; Output: 2007-02-18 00:00:00 If you want to insert new records in the table you can either use time() in php, or UNIX_TIMESTAMP(NOW()) in the query. HTH, -B -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Date/time format?
2007. 03. 28, szerda keltezéssel 14.48-kor Travis Doherty ezt írta: Zoltán Németh wrote: 2007. 03. 28, szerda keltezéssel 15.35-kor Jason Pruim ezt írta: Hi Everyone, First off, I'm using PHP 5.2.0 and apache 1.3.33 I am trying to figure out what format a string is in in a database. It's a timecard system that I have found on-line and I am attempting to figure out how to write a script that would give me everyones timecard for the month on one screen I can print out for accounting to use. Below is an example of one of the lines in the database, What I'm really interested in is how it represents the day. user dayjob_name minutes sequence root 1171774800 Production technology Manager 990 3 I have not been able to find ANY info about that format, other then other people using it in blogs. I think I can figure out the rest as I go if I know how to decode the day. Any help or pointers to the M would be GREATLY appreciated! :) what does strtotime return for that string? It's already a time, strtotime should return FALSE. It probably can't parse that string to a time. sorry I meant strftime ;) greets Zoltán Németh Travis D -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Date time Comparison
I'd agree with what Richard is alluding to: turn your two dates into timestamps, and then compare those. mktime() or strtotime() should help you out. HTH, John W On 4/18/06, Richard Lynch [EMAIL PROTECTED] wrote: http://php.net/mktime may be more suitable, depending on the date range of the input. That said, as far as I can tell, your $formated_expiry_date is the SAME as your $expiry_date, except possibly for some separation characters. If the separation characters are ALWAYS the same, you could just do: $current_date = date('Y/m/d H:i:s'); //match formatting of expiry date. return $current_date $expiry_date; On Tue, April 18, 2006 5:02 pm, Murtaza Chang wrote: Hi everyone, this is the function I have written for comparing a date time please tell me if my logic is correct ? and if there's a better alternative please let me know of that as well. // This function will return 1 if supplied date is expired function is_expire($expiry_date){ $current_date=date('YmdHis'); $year=substr($expiry_date,0,4); $month=substr($expiry_date,5,2); $day=substr($expiry_date,8,2); $hour=substr($expiry_date,11,2); $min=substr($expiry_date,14,2); $sec=substr($expiry_date,17,2); $formated_expiry_date=$year.$month.$day.$hour.$min.$sec; if ($current_date=$formated_expiry_date) return 1; else return 0; } -- Murtaza Chang -- 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 General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Date time Comparison
Hi everyone, this is the function I have written for comparing a date time please tell me if my logic is correct ? and if there's a better alternative please let me know of that as well. // This function will return 1 if supplied date is expired function is_expire($expiry_date){ $current_date=date('YmdHis'); $year=substr($expiry_date,0,4); $month=substr($expiry_date,5,2); $day=substr($expiry_date,8,2); $hour=substr($expiry_date,11,2); $min=substr($expiry_date,14,2); $sec=substr($expiry_date,17,2); $formated_expiry_date=$year.$month.$day.$hour.$min.$sec; if ($current_date=$formated_expiry_date) return 1; else return 0; } -- Murtaza Chang
Re: [PHP] Date time Comparison
http://php.net/mktime may be more suitable, depending on the date range of the input. That said, as far as I can tell, your $formated_expiry_date is the SAME as your $expiry_date, except possibly for some separation characters. If the separation characters are ALWAYS the same, you could just do: $current_date = date('Y/m/d H:i:s'); //match formatting of expiry date. return $current_date $expiry_date; On Tue, April 18, 2006 5:02 pm, Murtaza Chang wrote: Hi everyone, this is the function I have written for comparing a date time please tell me if my logic is correct ? and if there's a better alternative please let me know of that as well. // This function will return 1 if supplied date is expired function is_expire($expiry_date){ $current_date=date('YmdHis'); $year=substr($expiry_date,0,4); $month=substr($expiry_date,5,2); $day=substr($expiry_date,8,2); $hour=substr($expiry_date,11,2); $min=substr($expiry_date,14,2); $sec=substr($expiry_date,17,2); $formated_expiry_date=$year.$month.$day.$hour.$min.$sec; if ($current_date=$formated_expiry_date) return 1; else return 0; } -- Murtaza Chang -- 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/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/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 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/Time problem
Well, I got the time displaying sort of right but have a length problem. See, using %T doesn't work in date() but %Z does but it returns a very long string 'Mountain Daylight Time' when all I want is 'MDT'. Is there a way around this problem other than having to edit the string date() returns?? Robin E. Kopetzky Black Mesa Computers/Internet Services www.blackmesa-isp.net
Re: [PHP] Date/Time problem
echo(date('T')); Works fine for me. On Fri, 2003-06-27 at 13:03, Sparky Kopetzky wrote: Well, I got the time displaying sort of right but have a length problem. See, using %T doesn't work in date() but %Z does but it returns a very long string 'Mountain Daylight Time' when all I want is 'MDT'. Is there a way around this problem other than having to edit the string date() returns?? Robin E. Kopetzky Black Mesa Computers/Internet Services www.blackmesa-isp.net -- Adam Voigt ([EMAIL PROTECTED]) Linux/Unix Network Administrator The Cryptocomm Group -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] OOPS!!! [PHP] Date/Time problem
Opps! I meant strftime() as I have to pass timestamp from a file. Sparky - Original Message - From: Adam Voigt [EMAIL PROTECTED] To: Sparky Kopetzky [EMAIL PROTECTED] Cc: PHP General [EMAIL PROTECTED] Sent: Friday, June 27, 2003 11:07 Subject: Re: [PHP] Date/Time problem echo(date('T')); Works fine for me. On Fri, 2003-06-27 at 13:03, Sparky Kopetzky wrote: Well, I got the time displaying sort of right but have a length problem. See, using %T doesn't work in date() but %Z does but it returns a very long string 'Mountain Daylight Time' when all I want is 'MDT'. Is there a way around this problem other than having to edit the string date() returns?? Robin E. Kopetzky Black Mesa Computers/Internet Services www.blackmesa-isp.net -- Adam Voigt ([EMAIL PROTECTED]) Linux/Unix Network Administrator The Cryptocomm Group -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Date/Time Logic
Hello Everyone, My php/mysql application needs to keep track of the first time that a User logs on to the site. Afterwards the User should be allowed either 3 days / 3 months/1 year of access to the site. Once the stipulated time period is over the system should invalidate the login of the user. The Admin/ User should get email notification about this. The notification part is easy the hard part to figure out is how to be able to keep and tab on the Time Period stipulated for a user. Thanks in advance Pushpinder Singh Garcha _ Web Architect
Re: [PHP] Date/Time Logic
It sounds like you're asking for triggers, which are available yet. But you could setup a cron job to run every night to update the database. It would be no different than doing a nightly dump for backup. You could even have it email you the accounts that were closed and those that will be closing in the next week or two. If that won't work for you, then you can just have the user login kick of the disabling code. It would still restrict access, but wouldn't give you the timely notification you're asking for. On Wednesday, February 19, 2003, at 12:46 PM, Pushpinder Singh Garcha wrote: Hello Everyone, My php/mysql application needs to keep track of the first time that a User logs on to the site. Afterwards the User should be allowed either 3 days / 3 months/1 year of access to the site. Once the stipulated time period is over the system should invalidate the login of the user. The Admin/ User should get email notification about this. The notification part is easy the hard part to figure out is how to be able to keep and tab on the Time Period stipulated for a user. Thanks in advance Pushpinder Singh Garcha _ Web Architect -- 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/Time Logic
I assume you talking about a logged in, validated user -- because there's no way to prevent a user from deleting their cookies, or changing their IP, or using a different computer to access the site. My only suggestion is that you create a user/pass login system, maintain it with sessions, and make the site members-only. As part of the sign-up process, keep a timestamp of when they joined, and each time they log-in, check that their stamp is within the limits set. Next time they login after that date, you can use their login as the trigger to: a) set the account to invalid b) send the admin a report email c) update any other data and tables d) prompt the user to buy more time, or whatever By keeping timestamps of when they signed up, when they last logged in, you can also build reports about who has logged in, who is about to run out of time, who needs a reminder email sent about buying more time, and even run some garbage cleanout stuff, so that users who have expired, and haven't shown up in 2 months get auto-deleted or whatever. Some of it could be done with cron jobs, or you could just choose to run a script from your browser daily/weekly/yearly to trigger the processing. Justin on 20/02/03 5:50 AM, Brent Baisley ([EMAIL PROTECTED]) wrote: It sounds like you're asking for triggers, which are available yet. But you could setup a cron job to run every night to update the database. It would be no different than doing a nightly dump for backup. You could even have it email you the accounts that were closed and those that will be closing in the next week or two. If that won't work for you, then you can just have the user login kick of the disabling code. It would still restrict access, but wouldn't give you the timely notification you're asking for. On Wednesday, February 19, 2003, at 12:46 PM, Pushpinder Singh Garcha wrote: Hello Everyone, My php/mysql application needs to keep track of the first time that a User logs on to the site. Afterwards the User should be allowed either 3 days / 3 months/1 year of access to the site. Once the stipulated time period is over the system should invalidate the login of the user. The Admin/ User should get email notification about this. The notification part is easy the hard part to figure out is how to be able to keep and tab on the Time Period stipulated for a user. Thanks in advance Pushpinder Singh Garcha _ Web Architect -- 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 Time
On 21-Sep-2002 Patrick wrote: Hi,, my server is located in the US and i live in Sweden, so when i try to run the following command i get a 8hour diffrence,, anyone got any idea of how to solve this? date(Y-m-j) putenv('TZ=Europe/Stockholm'); mktime(0,0,0,1,1,1970); echo date(Y-m-j); -- Don Read [EMAIL PROTECTED] -- Beer is proof that God loves us and wants us to be happy. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Date Time
Hi,, my server is located in the US and i live in Sweden, so when i try to run the following command i get a 8hour diffrence,, anyone got any idea of how to solve this? date(Y-m-j) regards Patrick -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Date Time
Hi, Saturday, September 21, 2002, 12:30:48 PM, you wrote: P Hi,, P my server is located in the US and i live in Sweden, so when i try to run P the following command i get a 8hour diffrence,, anyone got any idea of how P to solve this? P date(Y-m-j) P regards P Patrick A quick fix that won't account for daylight saving differences unless Sweden uses the same dates as the US... date(Y-m-j,strtotime(+8 hours)); -- regards, Tom -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Date Time
You have to add (or subtract) 28800 seconds to/from current time and use this as the 2nd input to date. echo date(Y-m-j, strtotime(now) + 28800); Sascha Hi,, my server is located in the US and i live in Sweden, so when i try to run the following command i get a 8hour diffrence,, anyone got any idea of how to solve this? date(Y-m-j) regards Patrick -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Date/Time...
OK, give up.. been trying to compare dates in the format; 2002-05-23 12:19:34 I just cant workout how to compare, I've converted to a timestamp - but the resulting timestamp was wrong. Any help much appreciated... TIA... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Date/Time...
What are you trying to do? Compare dates from where to what? To the current time, to times in a database??? strtotime() and UNIX_TIMESTAMP() are probably going to be part of your solution, but I don't know what your doing. ---John Holmes... -Original Message- From: Brian McGarvie [mailto:[EMAIL PROTECTED]] Sent: Thursday, May 23, 2002 7:22 AM To: [EMAIL PROTECTED] Subject: [PHP] Date/Time... OK, give up.. been trying to compare dates in the format; 2002-05-23 12:19:34 I just cant workout how to compare, I've converted to a timestamp - but the resulting timestamp was wrong. Any help much appreciated... TIA... -- 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/Time...
I have an audit table which stores events like faile logins etc, they are stored with a time in the format 2002-05-23 12:19:34 i want to know the number of days between 'now' and the oldest date in the database. This is so I can give them a drop-down list of the number of days they might want to trim... say a 'date_a' - 'date_b' = '15' [days] they could select '5' for example and it'll remove all records older than 'now - 5' at present I have done this... $date_secs = strtotime ($date_oldest); changes the '2002-05-23 12:19:34' format date to a timestamp, however oldest time from database: converted to:972225660 converted back (1970-01-01 00:00:00) has lost it somewhere ;\ (fuller code) $date_oldest = $myrow[audit_timestamp]; $now = time(); // format both back to 'nice' dates $nice_now = date (Y-m-d H:i:s , $now); $nice_old = date (Y-m-d H:i:s , $date_secs); // change oldest date to timestamp $date_secs = strtotime ($date_oldest); echo now: .time().($nice_now), oldest time from database: $date_secs ($nice_old); // compute the difference $timediff = $date_secs - $now; //get the int val of the days passed $dayspassed = intval(abs$timediff/60)/60)/24))); echo brbrdays elapsed: $dayspassed; any ideas? on-top of what you mentioned? -Original Message- From: John Holmes [mailto:[EMAIL PROTECTED]] Sent: 23 May 2002 1:18 PM To: Brian McGarvie; [EMAIL PROTECTED] Subject: RE: [PHP] Date/Time... What are you trying to do? Compare dates from where to what? To the current time, to times in a database??? strtotime() and UNIX_TIMESTAMP() are probably going to be part of your solution, but I don't know what your doing. ---John Holmes... -Original Message- From: Brian McGarvie [mailto:[EMAIL PROTECTED]] Sent: Thursday, May 23, 2002 7:22 AM To: [EMAIL PROTECTED] Subject: [PHP] Date/Time... OK, give up.. been trying to compare dates in the format; 2002-05-23 12:19:34 I just cant workout how to compare, I've converted to a timestamp - but the resulting timestamp was wrong. Any help much appreciated... TIA... -- 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/Time...
Really only a mysql issue. To get the number of days between now and the oldest row in the table, use this query SELECT TO_DAYS(NOW()) - TO_DAYS(MIN(date_column)) AS Num_Days FROM table; To erase all rows that are older than $X days, use this query: DELETE FROM table WHERE date_column NOW() - INTERVAL $X DAY; Easy, eh? ---John Holmes... - Original Message - From: Brian McGarvie [EMAIL PROTECTED] To: [EMAIL PROTECTED]; [EMAIL PROTECTED] Sent: Thursday, May 23, 2002 8:27 AM Subject: RE: [PHP] Date/Time... I have an audit table which stores events like faile logins etc, they are stored with a time in the format 2002-05-23 12:19:34 i want to know the number of days between 'now' and the oldest date in the database. This is so I can give them a drop-down list of the number of days they might want to trim... say a 'date_a' - 'date_b' = '15' [days] they could select '5' for example and it'll remove all records older than 'now - 5' at present I have done this... $date_secs = strtotime ($date_oldest); changes the '2002-05-23 12:19:34' format date to a timestamp, however oldest time from database: converted to:972225660 converted back (1970-01-01 00:00:00) has lost it somewhere ;\ (fuller code) $date_oldest = $myrow[audit_timestamp]; $now = time(); // format both back to 'nice' dates $nice_now = date (Y-m-d H:i:s , $now); $nice_old = date (Y-m-d H:i:s , $date_secs); // change oldest date to timestamp $date_secs = strtotime ($date_oldest); echo now: .time().($nice_now), oldest time from database: $date_secs ($nice_old); // compute the difference $timediff = $date_secs - $now; //get the int val of the days passed $dayspassed = intval(abs$timediff/60)/60)/24))); echo brbrdays elapsed: $dayspassed; any ideas? on-top of what you mentioned? -Original Message- From: John Holmes [mailto:[EMAIL PROTECTED]] Sent: 23 May 2002 1:18 PM To: Brian McGarvie; [EMAIL PROTECTED] Subject: RE: [PHP] Date/Time... What are you trying to do? Compare dates from where to what? To the current time, to times in a database??? strtotime() and UNIX_TIMESTAMP() are probably going to be part of your solution, but I don't know what your doing. ---John Holmes... -Original Message- From: Brian McGarvie [mailto:[EMAIL PROTECTED]] Sent: Thursday, May 23, 2002 7:22 AM To: [EMAIL PROTECTED] Subject: [PHP] Date/Time... OK, give up.. been trying to compare dates in the format; 2002-05-23 12:19:34 I just cant workout how to compare, I've converted to a timestamp - but the resulting timestamp was wrong. Any help much appreciated... TIA... -- 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] date(), time() different to system time
Hey guys, I'm running a RH7.2 box with apache 1.3.20 installed and php-4.1.1 installed as a DSO. Everything is working fine, except that the output from any date() or time() references is 16 hours behind the system time (and hwtime) on the machine. The machine gets its time from an ntp server which is correct; this setup is similar for other boxes on the network which have no problems with the date or time in php being correct. If I output date('T') then the correct timezone (EST...I'm in Aus) is displayed, but any time or dates are 16 hours behind. Where does php read the time/date values from? Is there something I can tweak or something that I should look at to correct this? I know I could kludge around it in users php code by tacking an extra 16 hours onto each value but obviously that's not a good solution for a box which will be used by others! Any thoughts / headsup would be appreciated. cheers, Anth -- Anth Courtney - Systems Administrator / Programmer [EMAIL PROTECTED] - PLANET NETCOM - www.pnc.com.au -- -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] date(), time() different to system time
Hey Anth, Hey guys, =some of the better-looking amongst us are not guys (and then some of us are...) I'm running a RH7.2 box with apache 1.3.20 installed and php-4.1.1 installed as a DSO. Everything is working fine, except that the output from any date() or time() references is 16 hours behind the system time (and hwtime) on the machine. The machine gets its time from an ntp server which is correct; this setup is similar for other boxes on the network which have no problems with the date or time in php being correct. If I output date('T') then the correct timezone (EST...I'm in Aus) is displayed, but any time or dates are 16 hours behind. Where does php read the time/date values from? Is there something I can tweak or something that I should look at to correct this? I know I could kludge around it in users php code by tacking an extra 16 hours onto each value but obviously that's not a good solution for a box which will be used by others! Any thoughts / headsup would be appreciated. Check out the meaning of EST. Sixteen hours behind NSW, Australian time would make it New York time wouldn't it? Rather than the three-character codes, check out the +or- settings in the date functions to check that you and your server are in the same time zone. =dn -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] date(), time() different to system time
On Tue, 5 Feb 2002, DL Neil wrote: Hello DL, =some of the better-looking amongst us are not guys (and then some of us are...) Sorry! :) Check out the meaning of EST. Sixteen hours behind NSW, Australian time would make it New York time wouldn't it? *trumpet fanfare* Thanks for that. Problem is now fixed after adjusting the system time so that it is /now/ correct. cheers, Anth -- Anth Courtney - Systems Administrator / Programmer [EMAIL PROTECTED] - PLANET NETCOM - www.pnc.com.au -- -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Date time
Hello Torkil, I have a field in my mysql database containing datetime on the format -MM-DD HH:MM:SS (24-hour format) Now. I want to output this as follows: DD.MM.YY at HH:MM:SS Currently I do this by this function: function convert_datetime($in){ $return = substr($in,8,2) . . . substr($in,5,2) . . . substr($in,2,2) . at . substr($in,11,8); return $return; } Is there a better way? Either with mysql or php? =yes, please check the MySQL manual's section on Time/Date functions. There is a surprising list of them, and one will satisfy your needs more efficiently that the PHP routine. Now. Another problem. Since my webserver is in the states, and I live in Norway, I get a 7 hour time difference. So when I do date(Y-m-d H:i:s) I get a time that is 7 hours wrong. Any idea as to how I can correct this to be 7 hours later (that is: 12 in server time is really 19 where I live) in an easy way? =let me offer you further grounds for confusion: MySQL doesn't care! MySQL keeps no sense/location in time, it is fed a time/date value and it stores it. End of story. =If you ask PHP for time (and date) information, it will be taken from the server. How then is it supposed to work out where you/the client is. If you always want to adjust a server-based time by seven hours, then that is easy enough. If however you want to give local-time to the client, life gets much more interesting! =Either way, your reading will be from the PHP manual, and again the time-date facilities. Take careful note of the fact that there are two sets of functions, one for server time and the other for UTC (GMT or Zulu time). Note also that there are ways of getting time zone information/differences too. =I found it a lot easier to accept times from the client, and immediately convert them to UTC before storage in MySQL. When I retrieve data it is always stated to be UTC. The beauty of this is that I don't have to beat my brains trying to figure out the international implications of Summer Time and the twice yearly discontinuities so-caused. However this uniform and 'tidy' solution may not suit your requirements... =Regards, =dn -- 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] Date time
Hello... I have a field in my mysql database containing datetime on the format -MM-DD HH:MM:SS (24-hour format) Now. I want to output this as follows: DD.MM.YY at HH:MM:SS Currently I do this by this function: function convert_datetime($in){ $return = substr($in,8,2) . . . substr($in,5,2) . . . substr($in,2,2) . at . substr($in,11,8); return $return; } Is there a better way? Either with mysql or php? Now. Another problem. Since my webserver is in the states, and I live in Norway, I get a 7 hour time difference. So when I do date(Y-m-d H:i:s) I get a time that is 7 hours wrong. Any idea as to how I can correct this to be 7 hours later (that is: 12 in server time is really 19 where I live) in an easy way? THanks in advance, Torkil -- 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] Date time
It is much easier to use the mysql DATE_FORMAT() function to format your dates when retrieving directly from the data base. You do not have to convert to a UNIX time stamp and all that other stuff. Your select statement should look something like: $date_format_long=%d:%m:%y at %T; $query=select DATE_FORMAT(date_field, '$date_format_long' ) as fmt_date from your_table; RTM at http://www.mysql.com Chapter 6 - Original Message - From: Torkil Johnsen [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Tuesday, January 29, 2002 7:29 PM Subject: [PHP] Date time Hello... I have a field in my mysql database containing datetime on the format -MM-DD HH:MM:SS (24-hour format) Now. I want to output this as follows: DD.MM.YY at HH:MM:SS Currently I do this by this function: function convert_datetime($in){ $return = substr($in,8,2) . . . substr($in,5,2) . . . substr($in,2,2) . at . substr($in,11,8); return $return; } Is there a better way? Either with mysql or php? Now. Another problem. Since my webserver is in the states, and I live in Norway, I get a 7 hour time difference. So when I do date(Y-m-d H:i:s) I get a time that is 7 hours wrong. Any idea as to how I can correct this to be 7 hours later (that is: 12 in server time is really 19 where I live) in an easy way? THanks in advance, Torkil -- 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]
[PHP] date/time of current page
I want to put, into a footer include file, the last modified date of the current file being viewed. I have the following code that works when I hard code the file name - ? $dt=date(D, F d, Y g:i:s A, filemtime(index.php)); echo $dt; ? But of course that won't work as a footer for a site with over two hundred pages. What is the parameter for the current page? I tried php_self but that didn't work properly (it returned Dec 31 1969). -- Chip Wiegand Simrad, Inc [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] date/time of current page
have you tried parsing out the name from $PHP_SELF? I would think that php wouldn't care if it gets 'index.php' or (some processing) index.php, know what i mean? jack -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] Sent: Tuesday, September 11, 2001 1:01 PM To: [EMAIL PROTECTED] Subject: [PHP] date/time of current page I want to put, into a footer include file, the last modified date of the current file being viewed. I have the following code that works when I hard code the file name - ? $dt=date(D, F d, Y g:i:s A, filemtime(index.php)); echo $dt; ? But of course that won't work as a footer for a site with over two hundred pages. What is the parameter for the current page? I tried php_self but that didn't work properly (it returned Dec 31 1969). -- Chip Wiegand Simrad, Inc [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] -- 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] date/time of current page
script language=javascript document.write('some text ' + document.lastmodified + ' some other text.'); /script -Original Message- From: Jack Dempsey [mailto:[EMAIL PROTECTED]] Sent: Tuesday, September 11, 2001 4:42 PM To: [EMAIL PROTECTED]; [EMAIL PROTECTED] Subject: RE: [PHP] date/time of current page have you tried parsing out the name from $PHP_SELF? I would think that php wouldn't care if it gets 'index.php' or (some processing) index.php, know what i mean? jack -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] Sent: Tuesday, September 11, 2001 1:01 PM To: [EMAIL PROTECTED] Subject: [PHP] date/time of current page I want to put, into a footer include file, the last modified date of the current file being viewed. I have the following code that works when I hard code the file name - ? $dt=date(D, F d, Y g:i:s A, filemtime(index.php)); echo $dt; ? But of course that won't work as a footer for a site with over two hundred pages. What is the parameter for the current page? I tried php_self but that didn't work properly (it returned Dec 31 1969). -- Chip Wiegand Simrad, Inc [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] -- 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] date/time of current page
Jack Dempsey [EMAIL PROTECTED] on 09/11/2001 11:42:07 PM Internet mail from: To: [EMAIL PROTECTED], [EMAIL PROTECTED] cc: Subject: RE: [PHP] date/time of current page have you tried parsing out the name from $PHP_SELF? I would think that php wouldn't care if it gets 'index.php' or (some processing) index.php, know what i mean? jack I'm not sure what you mean, but here is what I have tried - ? $dt=date(m/d/y g:i:s A, filemtime($PHP_SELF)); echo $dt; ? I also quoted the string $PHP_SELF with the same results, which look like this - 12/31/69 4:00:00 PM So, just what am I doing wrong? -- Chip -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] Sent: Tuesday, September 11, 2001 1:01 PM To: [EMAIL PROTECTED] Subject: [PHP] date/time of current page I want to put, into a footer include file, the last modified date of the current file being viewed. I have the following code that works when I hard code the file name - ? $dt=date(D, F d, Y g:i:s A, filemtime(index.php)); echo $dt; ? But of course that won't work as a footer for a site with over two hundred pages. What is the parameter for the current page? I tried php_self but that didn't work properly (it returned Dec 31 1969). -- Chip Wiegand Simrad, Inc [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] -- 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] date/time of current page
Michael Geier, CDM Systems Admin [EMAIL PROTECTED] on 09/11/2001 11:46:50 PM Internet mail from: To: Jack Dempsey [EMAIL PROTECTED], [EMAIL PROTECTED], [EMAIL PROTECTED] cc: Subject: RE: [PHP] date/time of current page script language=javascript document.write('some text ' + document.lastmodified + ' some other text.'); /script Surely it can be done in PHP, which doesn't, of course, depend on whether or not the visitor has some options disabled or enabled in their browser. -- Chip -Original Message- From: Jack Dempsey [mailto:[EMAIL PROTECTED]] Sent: Tuesday, September 11, 2001 4:42 PM To: [EMAIL PROTECTED]; [EMAIL PROTECTED] Subject: RE: [PHP] date/time of current page have you tried parsing out the name from $PHP_SELF? I would think that php wouldn't care if it gets 'index.php' or (some processing) index.php, know what i mean? jack -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] Sent: Tuesday, September 11, 2001 1:01 PM To: [EMAIL PROTECTED] Subject: [PHP] date/time of current page I want to put, into a footer include file, the last modified date of the current file being viewed. I have the following code that works when I hard code the file name - ? $dt=date(D, F d, Y g:i:s A, filemtime(index.php)); echo $dt; ? But of course that won't work as a footer for a site with over two hundred pages. What is the parameter for the current page? I tried php_self but that didn't work properly (it returned Dec 31 1969). -- Chip Wiegand Simrad, Inc [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] -- 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] date/time of current page
I'm not sure what you mean, but here is what I have tried - try this: ? echo date(m/d/y g:i:s A, filemtime(substr($PHP_SELF,strrpos($PHP_SELF,'/')+1))) ? jack -- 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] date/time of current page
Thankyou, that works fine. -- Chip Jack Dempsey [EMAIL PROTECTED] on 09/12/2001 12:03:20 AM Internet mail from: To: [EMAIL PROTECTED] cc: [EMAIL PROTECTED] Subject: RE: [PHP] date/time of current page I'm not sure what you mean, but here is what I have tried - try this: ? echo date(m/d/y g:i:s A, filemtime(substr($PHP_SELF,strrpos($PHP_SELF,'/')+1))) ? jack -- 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] Date/Time Query Help
Okay, I need help with this one: I have a table with a column in the MySQL DATETIME format. (2001-07-24 13:02:02) I need a MySQL query that will select all the entries in it made within the last hour. I tried this, but it is not working correctly, what am I doing wrong? SELECT * FROM session WHERE (session.Date DATE_SUB(NOW(), INTERVAL 1 HOUR)) Thanks!!! Ryan Shrout -- 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] Date Time Formatting ??
OK I have read many examples, old posts etc, but I am looking for a detailed explanation as to how to do this. First is when I write to a mysql database using the now() function, the time stamp looks like so when I display the time back to the browser. 204:24:06 ( This should have been 12:24pm ) Also the Date Display like so: 2001-05-08 The Goal is to have the Time stamp looking like 12:24 (military time OK) and the date 05-08-2001 or even 05-08-01. The MySQL db looks like so: date -00-00 time 00:00:00 I don't seem to really be able to vary the DB format. Any examples or links to good docs appreciated Thanks... -- 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] Date Time Formatting ??
I think the best way to handle this is not to care what it looks like in the database. Store your dates as UNIX timestamps, and then they are easy to do calculations on and/or convert to any date format you like for displaying in your pages. Read up on date() and mktime() for more info (there are loads of examples in the user notes). HTH Jon -Original Message- From: Jack Sasportas [mailto:[EMAIL PROTECTED]] Sent: 08 May 2001 17:28 To: php Subject: [PHP] Date Time Formatting ?? OK I have read many examples, old posts etc, but I am looking for a detailed explanation as to how to do this. First is when I write to a mysql database using the now() function, the time stamp looks like so when I display the time back to the browser. 204:24:06 ( This should have been 12:24pm ) Also the Date Display like so: 2001-05-08 The Goal is to have the Time stamp looking like 12:24 (military time OK) and the date 05-08-2001 or even 05-08-01. The MySQL db looks like so: date -00-00 time 00:00:00 I don't seem to really be able to vary the DB format. Any examples or links to good docs appreciated Thanks... ** '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] Date Time Formatting ??
Here is what I am trying to do, but I get the wrong date: $t_data_array[1]=date(m/d/y,mysql_result($db_result,$db_record,'date')); Then I simply print the value in the arraythis date instead of 05/08/01 comes out 12/31/69 Thanks! Jon Haworth wrote: I think the best way to handle this is not to care what it looks like in the database. Store your dates as UNIX timestamps, and then they are easy to do calculations on and/or convert to any date format you like for displaying in your pages. Read up on date() and mktime() for more info (there are loads of examples in the user notes). HTH Jon -Original Message- From: Jack Sasportas [mailto:[EMAIL PROTECTED]] Sent: 08 May 2001 17:28 To: php Subject: [PHP] Date Time Formatting ?? OK I have read many examples, old posts etc, but I am looking for a detailed explanation as to how to do this. First is when I write to a mysql database using the now() function, the time stamp looks like so when I display the time back to the browser. 204:24:06 ( This should have been 12:24pm ) Also the Date Display like so: 2001-05-08 The Goal is to have the Time stamp looking like 12:24 (military time OK) and the date 05-08-2001 or even 05-08-01. The MySQL db looks like so: date -00-00 time 00:00:00 I don't seem to really be able to vary the DB format. Any examples or links to good docs appreciated Thanks... ** '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] -- ___ Jack Sasportas Innovative Internet Solutions Phone 305.665.2500 Fax 305.665.2551 www.innovativeinternet.com www.web56.net -- 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] Date Time Formatting ??
Are you *absolutely sure* that mysql_result($db_result, $dbrecord, 'date') contains a UNIX timestamp? IOW, if I inserted the lines: $unixdate = mysql_result($db_result,$db_record,'date'); echo $unixdate; I would see something like 989393400 on the screen? (Speaking from experience, I got this hugely messed up first time round... search for one of my posts a few months ago where I was passing a string to the date function if you fancy a chuckle) Cheers Jon -Original Message- From: Jack Sasportas [mailto:[EMAIL PROTECTED]] Sent: 08 May 2001 17:46 To: php Subject: Re: [PHP] Date Time Formatting ?? Here is what I am trying to do, but I get the wrong date: $t_data_array[1]=date(m/d/y,mysql_result($db_result,$db_record,'date')); Then I simply print the value in the arraythis date instead of 05/08/01 comes out 12/31/69 Thanks! Jon Haworth wrote: I think the best way to handle this is not to care what it looks like in the database. Store your dates as UNIX timestamps, and then they are easy to do calculations on and/or convert to any date format you like for displaying in your pages. Read up on date() and mktime() for more info (there are loads of examples in the user notes). HTH Jon ** '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] Date Time Formatting ??
On 08-May-01 Jack Sasportas wrote: snip The Goal is to have the Time stamp looking like 12:24 (military time OK) and the date 05-08-2001 or even 05-08-01. The MySQL db looks like so: date -00-00 time 00:00:00 I don't seem to really be able to vary the DB format. combine the date time: mystamp datetime .. select date_format(mystamp,'%m-%d%Y %r') as ts from blah; Any examples or links to good docs appreciated find /usr/local -name manual.txt -print | grep mysql http://www.mysql.com/manual.php Regards, -- Don Read [EMAIL PROTECTED] -- It's always darkest before the dawn. So if you are going to steal the neighbor's newspaper, that's the time to do it. -- 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] Date/Time Arithmetic
Hello, Is it possible to do some arithmetic with time/date values in PHP? for example, to calculate: today + 1050 days. today - 7 days. etc. I mean, does PHP have functions to perform these operations? Thanks, Erich Reimberg. PS. I'm new to PHP, and I didn't find anything like this in the FAQ Please Cc to my email: [EMAIL PROTECTED], for there are many posts in this group that my server seems to loose. -- 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] Date/Time Arithmetic
Is it possible to do some arithmetic with time/date values in PHP? for example, to calculate: today + 1050 days. today - 7 days. etc. I mean, does PHP have functions to perform these operations? $oneDay = 86400; // number of seconds in a day // 60 seconds * 60 minutes * 24 hours $today = date( "U" ); // lookup the date() function $oneWeekAgo = $today - ( $oneDay * 7 ); $1050Days = $today + ( $oneDay * 1050 ); echo "The date for one week ago is: "; echo date( "F d, Y", $oneWeekAgo ); echo "1,050 days in the future is: "; echo date( "F d, Y", $1050Days ); The unix timestamp is an awesome tool for date arithmetic. Time arithmetic uses the same logic but on a smaller scale. $oneMinute = 60; // seconds $oneHour = 3600; // seconds; 60 seconds * 60 minutes Chris
[PHP] date/time in wrong zone
I'm using php 4.0.4pl1on a FreeBSD system. When I use a php date/time function, it reports the time in GMT, however, I have the date on my FreeBSD system set to EDT. I can't figure out what the problem is here. The only thing I can think of is that when I compiled php, my system timezone was set to GMT and perhaps the local timezone is hardcoded into php. That doesn't make much sense though. I have changed my timezone to EDT since I compiled php. Any suggestions? Thanks. -- 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] date/time in wrong zone
It may also be relevant that the "T" format string for the date() function also reports GMT, even though I've set my system timezone to EDT. The command "date" in FreeBSD also reports the time in EDT. -Original Message- From: Duke [EMAIL PROTECTED] To: [EMAIL PROTECTED] [EMAIL PROTECTED] Date: April 9, 2001 12:00 AM Subject: [PHP] date/time in wrong zone I'm using php 4.0.4pl1on a FreeBSD system. When I use a php date/time function, it reports the time in GMT, however, I have the date on my FreeBSD system set to EDT. I can't figure out what the problem is here. The only thing I can think of is that when I compiled php, my system timezone was set to GMT and perhaps the local timezone is hardcoded into php. That doesn't make much sense though. I have changed my timezone to EDT since I compiled php. Any suggestions? Thanks. -- 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]
[PHP] Date/Time from Unix timestamp
Ok, I have looked at all my sources, including the manual and I cannot find any method of converting the Unix timestamp to a displayable date/time. I have probably just overlooked it each time, but all I can find are methods to convert the current date/time to a Unix timestamp. Can anyone give me an example? iewhat date/time does 977676902 come out to? Thanks CDitty -- 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] Date/Time from Unix timestamp
CDitty [[EMAIL PROTECTED]] wrote: Ok, I have looked at all my sources, including the manual and I cannot find any method of converting the Unix timestamp to a displayable date/time. I have probably just overlooked it each time, but all I can find are methods to convert the current date/time to a Unix timestamp. Can anyone give me an example? iewhat date/time does 977676902 come out to? Look at http://www.php.net/manual/en/html/ref.datetime.html, specifically "date" for converting a unix timestamp into a usable date, and "mktime" for converting a date into a unix timestamp. HTH. -- Hardy Merrill Mission Critical Linux, Inc. http://www.missioncriticallinux.com -- 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] Date/Time Formatting
On Fri, 19 Jan 2001, Jamie wrote: I'm fairly new to SQL and PHP and I'm haveing trouble useing the Date functions of Both Systems, so I'd be greatfull if someone can help. What I'm trying to do is have an 'administrator' be able to enter info through a form to a mySQL database. Then on a seperate page have the info reread and displayed. The basic outline is a News page which reads and displays from the table and shows the News topics preceeding and inculding the current date (ie if I enter a future Date eg 25/12/2001 and the comment Merry christmas, in the databaes I don't want it to appear until the date has occured) The Table looks as follows: CREATE TABLE news ( news_id INT NOT NULL primary key auto_increment, topic VARCHAR(30) NOT NULL, live_date dateNOT NULL, news BLOBNOT NULL, user_id VARCHAR(20) NOT NULL); I've used the MYSQL date type as I think this would be easier for the users to be able to manually enter the date in is form on the admin form - also I don't think a more accurate date/time method will be more usful. Currently I'm using this SQL Line: SELECT * FROM news ORDER BY live_date DESC LIMIT 4 (where Live_Date is the date to display the news after) Also I'd like to if possible to be able to enter and display the date in Australian / European Time format (DD,MM,) I'm currently entering it on the form using three text fields and then rearanging them to the Format in mySQL and indserting it as a string, but I don't know how to 'break' up a mySQL Date value to rearange it. Hope these arn't in the FAQ as I have spent some time looking through PHP script sites and have been unable to find anything that can help. The reason you haven't found anything on PHP sites is that they're not PHP questions, they're MySQL questions :) For the future date, add "live_date=NOW()" to your WHERE clause in your select queries. As for the date format, MySQL only supports ANSI format (-MM-DD) for input, but you can use the DATE_FORMAT() function to change the output. You'll have to use substr() in PHP to chop up the input string and rearrange it for MySQL. -- Ignacio Vazquez-Abrams [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] Date/Time Formatting
Also I'd like to if possible to be able to enter and display the date in Australian / European Time format (DD,MM,) I'm currently entering it on the form using three text fields and then rearanging them to the Format in mySQL and indserting it as a string, but I don't know how to 'break' up a mySQL Date value to rearange it. The breaking up of a MySQL date would be in the MySQL manual at http://mysql.org I dunno what it's called... In PostgreSQL it's "date_part" though :-) I'm afraid there was another question in there somewhere, but I couldn't really discern it -- What you are doing seems quite reasonable to me. -- 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]