[PHP] unix timestamp
Hi everybody, I am trying to create a unix timestamp which dates back a certain amount of days. Lets say I would like to have a unix timestamp from 7 days ago. what I tryed is just to subtract values since this are counted s since the start of the unix epoche, but this does not work in cases like the switch of months. Has anybody an idea how to do that? Thanx, Andy -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] unix timestamp
Hi Andy, I am trying to create a unix timestamp which dates back a certain amount of days. Lets say I would like to have a unix timestamp from 7 days ago. what I tryed is just to subtract values since this are counted s since the start of the unix epoche, but this does not work in cases like the switch of months. A quick and dirty way is to subtract 86400 from the current timestamp to push it back one day, so it would be (7*86400)=604800 for a week. This isn't the best method though - you should be able to do calculations within mktime(). If you post the code you tried we can have a look. Cheers Jon -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] unix timestamp
Hi, You can just use : $output = strtotime(+1 day); $output = strtotime(-7 day); http://dk.php.net/manual/en/function.strtotime.php -Morten Skou -Original Message- From: andy [mailto:[EMAIL PROTECTED]] Sent: 6. september 2002 13:50 To: [EMAIL PROTECTED] Subject: [PHP] unix timestamp Hi everybody, I am trying to create a unix timestamp which dates back a certain amount of days. Lets say I would like to have a unix timestamp from 7 days ago. what I tryed is just to subtract values since this are counted s since the start of the unix epoche, but this does not work in cases like the switch of months. Has anybody an idea how to do that? Thanx, Andy -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] unix timestamp
The attached class is a date utility that I created a long time ago. It parses out SQL dates, does differences, and specific to your needs, you can use dateAdjust() to move a unix timestamp by a number of seconds, minutes, hours, days, months, quarters, years or centuries. You should be able to either employ this class, or simply look through the code to find the answers to most of your date woes. The only thing this class doesn't do, is account for leap years, when working with quantities that span multiple months. (never got around to this yet, suppose I will need to before 2004!) Attached is also a short readme to explain what the functions are and what they do (the code itself is also well commented). Best wishes! Michael phpzen -Original Message- From: andy [mailto:[EMAIL PROTECTED]] Sent: Friday, September 06, 2002 4:50 AM To: [EMAIL PROTECTED] Subject: [PHP] unix timestamp Hi everybody, I am trying to create a unix timestamp which dates back a certain amount of days. Lets say I would like to have a unix timestamp from 7 days ago. what I tryed is just to subtract values since this are counted s since the start of the unix epoche, but this does not work in cases like the switch of months. Has anybody an idea how to do that? Thanx, Andy -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] unix timestamp
$date = date(U,strtotime(-7 day)); Have a nice day. Adam Voigt [EMAIL PROTECTED] On Fri, 2002-09-06 at 12:37, Mike richardson wrote: The attached class is a date utility that I created a long time ago. It parses out SQL dates, does differences, and specific to your needs, you can use dateAdjust() to move a unix timestamp by a number of seconds, minutes, hours, days, months, quarters, years or centuries. You should be able to either employ this class, or simply look through the code to find the answers to most of your date woes. The only thing this class doesn't do, is account for leap years, when working with quantities that span multiple months. (never got around to this yet, suppose I will need to before 2004!) Attached is also a short readme to explain what the functions are and what they do (the code itself is also well commented). Best wishes! Michael phpzen -Original Message- From: andy [mailto:[EMAIL PROTECTED]] Sent: Friday, September 06, 2002 4:50 AM To: [EMAIL PROTECTED] Subject: [PHP] unix timestamp Hi everybody, I am trying to create a unix timestamp which dates back a certain amount of days. Lets say I would like to have a unix timestamp from 7 days ago. what I tryed is just to subtract values since this are counted s since the start of the unix epoche, but this does not work in cases like the switch of months. Has anybody an idea how to do that? Thanx, Andy -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Unix timestamp
Hi List.. How do I convert this Sep 20 2000 00:00:00 into UNIX timestamp so that I can use the toDate() function to again convert it to the earlier format. I need to do this becoz I am moving from one table to another table where I get error, if I already have the converted date value with me. Pls. help. Thanks in adv. ~ Karthick -- 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] Unix timestamp
mktime -- Get UNIX timestamp for a date Description int mktime (int hour, int minute, int second, int month, int day, int year [,int is_dst]) Parse that list of values into the respective variables and pass them to mktime -jack TV Karthick Kumar wrote: Hi List.. How do I convert this Sep 20 2000 00:00:00 into UNIX timestamp so that I can use the toDate() function to again convert it to the earlier format. I need to do this becoz I am moving from one table to another table where I get error, if I already have the converted date value with me. Pls. help. Thanks in adv. ~ Karthick -- 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]