Hey frndz i m new member of community..!!
.
.
i jst want to knw is there anyway to get the previous month starting and ending date and which is the previoes month..!!!!
.
.
.
.
hope for positive reply..!!
nish123 0 Junior Poster in Training
Recommended Answers
Jump to Posti am giving an idea
$current_month=date('m'); $current_year=date('Y');
apply if condition that if current month is greater than one and less and equal to 12 then
$lastmonth=$current_month-1;
offcource the first date will be 1st and you can take end date as
$firstdate= …
Jump to Postwhat to confused..
you can write..
if($current_month==1) { $lastmonth=12; } else { $lastmonth=$current_month-1; }
Jump to PostNop, The above logic will give you the correct output unless no mistake in your code..
And see this is another logic:As we know the first day of the month and for the last month , here i calculated number of days of last month, then that number …
Jump to PostI think mktime deals correctly with overflows - no need for the conditional.
A DateTime alternative:
$months_ago = 1; $date = new DateTime(); $date->sub(new DateInterval('P'.$months_ago.'M')); echo "START : " . $date->format('Y-m-1') . " FINISH: " . $date->format('Y-m-t');
All 15 Replies
BzzBee 5 Posting Whiz
nish123 0 Junior Poster in Training
Shanti C 106 Posting Virtuoso
BzzBee 5 Posting Whiz
BzzBee 5 Posting Whiz
nish123 0 Junior Poster in Training
nish123 0 Junior Poster in Training
Shanti C 106 Posting Virtuoso
minnujp 0 Newbie Poster
tomdchi 0 Newbie Poster
no_matter 0 Newbie Poster
websourceblog 0 Newbie Poster
clandestine8 0 Newbie Poster

diafol
Webiswide 0 Newbie Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.