Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question appears to be off-topic because it lacks sufficient information to diagnose the problem. Describe your problem in more detail or include a minimal example in the question itself.
Closed 8 years ago.
Improve this question
I have a date that is currently formatted as 'y.m.d' and I need it formatted as 'D, M d, Y'. I've tried everything I can think of, but it always seems to get confused. Usually, a date that is listed as '11.11.27' comes out as 'Wed, Dec 31, 1969' somehow... Any thoughts as to why that happens (really? 1969??) or how to properly perform this conversion would be greatly appreciated.
You can use the DateTime::createFromFormat() method.
For example:
<?php
$date = DateTime::createFromFormat('y.m.d', '11.12.03');
echo $date->format('D, M d, Y');
?>
This should do it for you:
echo date('D, M d, Y', strtotime(str_replace('.','-',$yourDate)));
Related
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question appears to be off-topic because it lacks sufficient information to diagnose the problem. Describe your problem in more detail or include a minimal example in the question itself.
Closed 8 years ago.
Improve this question
I'm trying to format a date like Google specifies to format it
the format specified by Google is :
" JJJJ-MM-TTTss:mmZZZ "
What I tried so far is:
var_dump(date_format($date,'Y-M-D H:m:s'));
results in
"2013-Aug-Wed 18:08:37"
when I try to uses googles format like
var_dump(date_format($date,'JJJJ-MM-TTTss:mmZZZ'));
it results in
JJJJ-AugAug-CESTCESTCEST3737:0808720072007200"
I have no idea what it should look like, any help?
thanks in advance
What about this?
$date = date_create();
print date_format($date, 'Y-m-d\TH:iT');
Output:
2014-03-24T10:43CET
As i understand you are reading non english version of google manual, in english this date format looks like
YYYY-MM-DDThh:mmTZD
and example of this is
1997-07-16T19:20+01:00
You can try to produce this in PHP like this
echo date("Y-m-d\TH:s", time());
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question appears to be off-topic because it lacks sufficient information to diagnose the problem. Describe your problem in more detail or include a minimal example in the question itself.
Closed 9 years ago.
Improve this question
I want to find first day of next month.
So i use
$firstDayNextMonth = date('Y-m-01', strtotime('first day of next month'));
but it was not working in server.
Then i found a question in stackoverflow. Solution use
$firstDayNextMonth =`date('Y-m-d', mktime(0,0,0,date('n')-1,1,date('Y')))`
but that give wrong answer.
<?php
echo date('Y-m-d', mktime(0,0,0,date('n')+1,1,date('Y')));
?>
demo
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
I'm having an application in PHP which I want to foresight how it works in certain situations which I need to rewind the time to the future.
Is there any ways to do this?
I could only find timezone function which let me change the time zone but what I want us to change it to the future like... 3weeks or something like that.
There are a bunch of ways to do this with PHP. Here's one:
$future = date("Y-m-d", strtotime("+3 weeks"));
Here's another:
$future = (new DateTime())->modify("+3 weeks")->format("Y-m-d");
Here's another:
$future = (new DateTime())->add(new DateInterval("P21D"))->format("Y-m-d");
Sounds like a job for fluxcapacitor if you're running on Linux
You can do it with
date('l jS F (Y-m-d)', strtotime('3 week'));
or
date('l jS F (Y-m-d)', strtotime('21 days')); // for future 3 weeks
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
Anyone knows how to pull and display the date a member sign up through your website using phpmyadmin following the format: DD/MM/YYYY example: <?php echo $row->date; ?> maybe? I am assuming something similar to this will work: echo date("l jS \of F Y h:i:s A"); but would be more the date a member joined not the current date.
Any help is greatly appreciated,
if $row->date is some date/time string, one way would be to use strtotime.
$time = strtotime($row->date);
//then use the date function as you need
$date = date('d/m/Y', $time);
echo $date;
if you want an sql query
SELECT date(date,%d/%m/%Y) FROM tbl_name
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
I've a string like "2013-05-07"
and I want to convert it in "7 May 2013" via any functional way (if available) or in short method as possible
$dt = new DateTime('2013-05-07');
echo $dt->format('j F Y');
As of PHP 5.4
echo (new DateTime('2013-05-07'))->format('j F Y');
PHP Date Format
echo date('j F Y', strtotime("2013-05-07"));