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
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
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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.