I have date in the format 200901(YYYYMM FORMAT)
now I want to find the end date in the format(yyyy-mm-dd)
5 1683
Care to explain a little more? I don't see a question.
WHere do you get the original format from? If your starting format is simply numbers I think the string will need to be split (explode() or something) into it's year and month and then you will have to re-declare it as a date so you can use PHP's built-in date format function.
I'm no mind reader either but I could tell he's got only a month in the first format and by "end date" s/he means the last day of the given month.
Here's the code: -
-
$firstDate = "200905"; // example may is 31 days, should return 2009-05-31
-
-
// Get the month and year
-
$year = substr($firstDate,0,4);
-
$month = substr($firstDate,5,2);
-
-
// get a TimeStamp of the first day
-
$firstDateTS = mktime(0,0,0,$month,1,$year);
-
-
// get the last day of that month.
-
$day = date("t",$date);
-
-
// convert it to a timeStamp again
-
$endDateTS = mktime(0,0,0,$month,$day,$year);
-
$endDate = date("Y-m-d",$endDateTS);
-
-
// OR just print it
-
$endDate = "$year-$month-$day";
-
-
-
echo $endDate;
-
-
Hope that helps,
Dan
@Markus
Technically, you're right; however the OP did declare what s/he wanted...in as grammatically correct way as s/he could.
@dlite922
While I agree that there was no real question and also agree with your solution dlite, I also see where the OP could be asking how to figure out what the day referred to is, which would be a bit impossible without being told what the day is.
Regards,
Jeff
Sign in to post your reply or Sign up for a free account.
Similar topics
by: androtech |
last post by:
Hello,
I'm looking for a function that returns a date range for a specified week
number of the year.
I'm not able to find functions like this anywhere. Any pointers/help would
be much...
|
by: Benny Chow |
last post by:
Hello,
I need help in writing a SQL statement in MS SQL Server 2000 to select
the latest date (i.e., the date closest to or equal to the current date)
for a given date.
For example, in a...
|
by: sandy |
last post by:
Hello,
I am trying to automate a date. When typing in the issue date I
want it to automatically calculate 6 months fronm the issue date and
give me the Expiration date. Following is code that I am...
|
by: Lee Harr |
last post by:
I wrote a function to return the first date of a given week
(and a few related functions) :
-- return the first date in the given week
CREATE or REPLACE FUNCTION week_start(integer, integer)...
|
by: johndcal |
last post by:
Hello All,
I have a date value that I pull from a .csv file.
After reading the file and storing the values in an array the value of
the date could
be found in $array, for example....
|
by: Richiep |
last post by:
I am trying to get a UK format date of dd/mm/yyyy.
Why does the following subroutine not return a valid date in a web form?
The date returned is #12:00:00 AM# but the date I entered into the...
|
by: Jana |
last post by:
Greetings Access Gurus! I am working on an app to send batch
transactions to our bank, and the bank requires that we place an
effective date on our files that is 'one business day in the future,...
|
by: perryclisbee via AccessMonster.com |
last post by:
I have dates of service for several people that range all over each month.
ie: patient had dates of service of: 7/3/2006, 7/24/2006 and 7/25/2006. I
need to create a new field via a query that...
|
by: Andrew |
last post by:
Having trouble with some date computations. I need to get the date of a
specific day within a month - the 1st Thursday or the 2nd Monday, etc. I
found an article (...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
| |