Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 1 year ago.
Improve this question
I am looking for a similar PHP date function. I need the current month's first day. This month is September. the September month's first day is Wednesday. I need this one like this. Advance Thanks
Here you go:
$thisMonthsFirstDay = (new DateTime('first day of this month'))->format('l');
Also always take a look into the documentation, you can learn a lot from there.
Related
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
Say:
The start day is January 5 and the end is January 10 and the current date is January 7. I want to output the remaining days which is 3.
I think the easiest method is like this.
$date1 = new DateTime("2015-01-01");
$date2 = new DateTime("2010-02-05");
$diff = $date2->diff($date1)->format("%a");
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
I have a form which user submits and I get the current time and date in the database and facebook ID of the user as well, As per rule the user can fill the form only once in a week, so if he fills the form on Tuesday, he is not eligible to fill the form unless the week is complete, (Only eligible to complete the form again on next Monday)
I am trying to find some php function for weeks but couldn't get so, Anyone can help me what can be done for this logic?
I have date/time in the db for me.
First, you are basically looking for
$date = "2014-10-13";
$week=date("W", strtotime($date));
or even use it this way
$date = "2014-10-13";
$date = new DateTime($date);
$week = $date->format("W");
( http://php.net/manual/en/function.date.php )
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
I am trying to automatically create an array of the past 12 week numbers.
My immediate solution would be to do this:
for($week_number = date('W'); $week_number>date('W') - 12; $week_number--){
$week_numbers[] = $week_number;
}
This will return an array of the past 12 week numbers (not tested).
However, my question is, is there a better way of achieving this? Is the for loop necessary?
No, the range function is a much cleaner way of doing the same:
$week_numbers = range(date('W'), date('W') - 11, -1);
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 9 years ago.
Improve this question
A third party API is outputting: "1373762187.198" as a valid date time.
When passed through PHPs date function, I get todays date even though I know the object its attached to is over a week old.
Any ideas how todo a correct conversation?
Just strip the decimals away with an integer cast and then pass it to date (or do you need the milliseconds?)
date("...", (int)$date);
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I tried to get events from google calendar. So I have trouble in time output.
$date = DateTime::createFromFormat("Y-m-d\TH:m:sP", "2013-02-12T21:00:00-05:00");
echo $date->format('H:m');
Output is 21:12, but it should be 21:00. How it can be fixed?
m is months. You're looking for minutes which is i:
$date = DateTime::createFromFormat("Y-m-d\TH:i:sP", "2013-02-12T21:00:00-05:00");
echo $date->format('H:i');