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
Related
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 want to update a date in a table using a prepared statement. The date is in DD/MM/YY format in the form, and so I need to get it into YYYY-MM-DD format for my MySQL database. So I'm trying to use the STR_TO_TIME() function.
However, I can't work out how to include it in my query when using a (procedural) prepared statement, and I can't find any examples online. Can anyone help? Or is there a better way to do it with PHP?
Use DateTime.
$date = '07/01/14';
$dt = DateTime::createFromFormat('d/m/y', $date);
echo $dt->format('Y-m-d'); // 2014-01-07
Take a look at the PHP Documentation http://www.php.net/manual/en/datetime.format.php
Object oriented style
<?php
$date = new DateTime('2000-01-01');
echo $date->format('Y-m-d H:i:s');
?>
Procedural style
<?php
$date = date_create('2000-01-01');
echo date_format($date, 'Y-m-d H:i:s');
?>
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
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"));
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions must demonstrate a minimal understanding of the problem being solved. Tell us what you've tried to do, why it didn't work, and how it should work. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
i want to increment the current date by one month which is in d/m/Y format
but i have no idea about this,can any one give me a relevant example.
thanks in advance
In PHP you do this:
$time = strtotime("+1 month", time());
$date = date("d/m/Y", $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 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)));