Jump to content

date time function


fantomel

Recommended Posts

hello i got this small function i`m working on to get the date of a month something like get current date - 1 but not sure how to handle jan month can someone help me please ?

 

 

 

$month = date('m') - 1;$date_startt = date('Y').'-'.$luna.'-01';$timestamp_start = strtotime($data_start);

 

Link to comment
https://forums.phpfreaks.com/topic/215462-date-time-function/
Share on other sites

can you explain what your final result should be? also, where is $luna defined?

 

 

umm sorry my bad

 

 

$month = date('m') - 1;$date_startt = date('Y').'-'.$month.'-01';$timestamp_start = strtotime($date_startt);

 

 

well the final result should be like this:

today : Sat 31 Oct 2010

and i want to find out the date of a month ago and if it's January you know that Jan sometimes got +1 day or -1 one day and i need to calculate this correct.

Link to comment
https://forums.phpfreaks.com/topic/215462-date-time-function/#findComment-1120403
Share on other sites

The number of days in January never changes. Do you mean February? Here is how I would get the time of one month ago:

 

 

$now_parts = get_date();$time_one_month_ago = mktime($now_parts['hours'], $now_parts['minutes'], $now_parts['seconds'], $now_parts['mon'] - 1, $now_parts['mday'], $now_parts['year']);

 

 

but if you want 30 days instead of 1 month it would be this:

 

 

$now_parts = get_date();$time_one_month_ago = mktime($now_parts['hours'], $now_parts['minutes'], $now_parts['seconds'], $now_parts['mon'], $now_parts['mday'] - 30, $now_parts['year']);

 

Link to comment
https://forums.phpfreaks.com/topic/215462-date-time-function/#findComment-1120418
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.