how to I convert a unix timestamp 1280214000 to human readable date?
you can also use the date function
http://us.php.net/manual/en/function.date.php
<?php
// Assuming today is March 10th, 2001, 5:16:18 pm, and that we are in the
// Mountain Standard Time (MST) Time Zone
$today = date("F j, Y, g:i a"); // March 10, 2001, 5:16 pm
$today = date("m.d.y"); // 03.10.01
$today = date("j, n, Y"); // 10, 3, 2001
$today = date("Ymd"); // 20010310
$today = date('h-i-s, j-m-y, it is w Day'); // 05-16-18, 10-03-01, 1631 1618 6 Satpm01
$today = date('\i\t \i\s \t\h\e jS \d\a\y.'); // it is the 10th day.
$today = date("D M j G:i:s T Y"); // Sat Mar 10 17:16:18 MST 2001
$today = date('H:m:s \m \i\s\ \m\o\n\t\h'); // 17:03:18 m is month
$today = date("H:i:s"); // 17:16:18
?>
Just pass in your unix timestamp as the second parameter.
You can use strftime. E.g.:
strftime("%x", 1280214000);
See the documentation for all the formatting options.
You can use date:
date('Y-m-d H:i:s', $timestamp);
//Monday 8th of August 2005 03:12:46 PM
echo(date("l jS \of F Y h:i:s A", "1280214000"));
You can use the date function.
http://php.net/manual/en/function.date.php
Related
In PHP, what is the correct format pattern with date_format function to render date value '2014-06-18' as '18/jun'?
This is the code I tried but didn't work
<h3><?=date_format($evento->fecha,'j/M') ?></h3>
You'd want to employ both strtotime() and date() in something like this:
echo date('d/M', strtotime('2014-06-18')) //outputs 18/Jun
From the manual
$today = date("F j, Y, g:i a"); // March 10, 2001, 5:16 pm
$today = date("m.d.y"); // 03.10.01
$today = date("j, n, Y"); // 10, 3, 2001
$today = date("Ymd"); // 20010310
$today = date('h-i-s, j-m-y, it is w Day'); // 05-16-18, 10-03-01, 1631 1618 6 Satpm01
$today = date('\i\t \i\s \t\h\e jS \d\a\y.'); // it is the 10th day.
$today = date("D M j G:i:s T Y"); // Sat Mar 10 17:16:18 MST 2001
$today = date('H:m:s \m \i\s\ \m\o\n\t\h'); // 17:03:18 m is month
$today = date("H:i:s"); // 17:16:18
$today = date("Y-m-d H:i:s"); // 2001-03-10 17:16:18 (the MySQL DATETIME format)
I have this date in my database 11/06/2013 12:00
This is my code and the format I would like it in
$dateformatstart = date_format(date_create($row['datestart']), 'D j M y H:i');
Although it comes back as
Wed 6 Nov 13 12:00
Think the month is the day and day is the month, I don't know why
Thanks
Maybe this helps:
$date = DateTime::createFromFormat('d/m/Y H:i', $row['datestart']);
$dateformatstart = date_format($date, 'D j M y H:i');
Have you even checked out the php manual before asking this question?
Well, Here are some clever ways on how to format dates in PHP
<?php
// Assuming today is March 10th, 2001, 5:16:18 pm, and that we are in the
// Mountain Standard Time (MST) Time Zone
$today = date("F j, Y, g:i a"); // March 10, 2001, 5:16 pm
$today = date("m.d.y"); // 03.10.01
$today = date("j, n, Y"); // 10, 3, 2001
$today = date("Ymd"); // 20010310
$today = date('h-i-s, j-m-y, it is w Day'); // 05-16-18, 10-03-01, 1631 1618 6 Satpm01
$today = date('\i\t \i\s \t\h\e jS \d\a\y.'); // it is the 10th day.
$today = date("D M j G:i:s T Y"); // Sat Mar 10 17:16:18 MST 2001
$today = date('H:m:s \m \i\s\ \m\o\n\t\h'); // 17:03:18 m is month
$today = date("H:i:s"); // 17:16:18
$today = date("Y/m/d H:i"); // 2001-03-10 17:16:18 (the MySQL DATETIME format)
If you are trying to output a data format like this :
11/06/2013 12:00
then better, Use
$today = date("d/m/Y H:i");
I urgently need to know how I can make dates appear in Spanish instead of in English in reminder emails sent to users via a cron task. With the current (".$upcoming_date."), the date shown in the emails is like this: Saturday, 26 November, 2011 21:19, and I would need this to change into the corresponding Spanish version or into something like 26/11/2011 21:19.
You will maybe need this function to convert the time if it is store somewhere. Good luck.
http://php.net/manual/en/function.strtotime.php
http://php.net/manual/en/function.date.php
$today = date("F j, Y, g:i a"); // March 10, 2001, 5:16 pm
$today = date("m.d.y"); // 03.10.01
$today = date("j, n, Y"); // 10, 3, 2001
$today = date("Ymd"); // 20010310
$today = date('h-i-s, j-m-y, it is w Day'); // 05-16-18, 10-03-01, 1631 1618 6Satpm01
$today = date('\i\t \i\s \t\h\e jS \d\a\y.'); // it is the 10th day.
$today = date("D M j G:i:s T Y"); // Sat Mar 10 17:16:18 MST 2001
$today = date('H:m:s \m \i\s\ \m\o\n\t\h'); // 17:03:18 m is month
$today = date("H:i:s"); // 17:16:18
You don't. You change the value of the $format argument you pass to strftime().
strftime(_($someformat), $sometime)
For spanish dates ,You can do:
echo strftime("%A %e de %B del %Y - %H:%M:%S", mktime (gmdate("H"), gmdate("i"), gmdate("s")-16200, gmdate("n"), gmdate("j"), gmdate("Y")));
Hope it helps
I have created a script through which i retrieve values from a rss feed.
One value is in following date format:
Thu, 14 Apr 2011 18:23:19 GMT
What i wanted this value to be in following format:
April 14, 2011 11:53 PM
How can i achieve this?
Please help me on this
Thanks
Pankaj
The DateTime class is handy for this. You can use its format() method.
$datetime = new DateTime('Thu, 14 Apr 2011 18:23:19 GMT');
echo $datetime->format('F j,Y g:i A');
$olddate = "Thu, 14 Apr 2011 18:23:19 GMT";
$newdate = date("F d, Y H:i A",strtotime($oldDate));
Try it:
echo (date('F j,Y g:i:A',strtotime($Yourinputdate)));
<?php
// Assuming today is March 10th, 2001, 5:16:18 pm, and that we are in the
// Mountain Standard Time (MST) Time Zone
$today = date("F j, Y, g:i a"); // March 10, 2001, 5:16 pm
$today = date("m.d.y"); // 03.10.01
$today = date("j, n, Y"); // 10, 3, 2001
$today = date("Ymd"); // 20010310
$today = date('h-i-s, j-m-y, it is w Day'); // 05-16-18, 10-03-01, 1631 1618 6 Satpm01
$today = date('\i\t \i\s \t\h\e jS \d\a\y.'); // it is the 10th day.
$today = date("D M j G:i:s T Y"); // Sat Mar 10 17:16:18 MST 2001
$today = date('H:m:s \m \i\s\ \m\o\n\t\h'); // 17:03:18 m is month
$today = date("H:i:s"); // 17:16:18
?>
above code taken from : http://www.php.net/manual/en/function.date.php
i didnot see you have an input so here it is:
$date = new DateTime('Thu, 14 Apr 2011 18:23:19 GMT');
echo $date->format("F j, Y g:i a");
Try this and see if it helps
echo(date('F j,Y g:i:A',strtotime(Date_From_RSS)));
This question goes along with another one of my post that I already accepted
How do I get the "date number" in php
2010-08-24 20:00:00.000
I want to assign the current date number to a variable $current_date_num so I can use it in my query to compare what is already in the database.
$query ="SELECT * FROM Reservations WHERE [Room_ID] = '$field' AND [Meeting Start] > '$current_date_num' ORDER BY [Meeting Start] asc ";
If you are only using it in the database, consider NOW
To get the current date number in the format above you would do:
echo date("Y-m-d H:i:s.u")
well, you can get the date number like this.. ex. from php.net http://php.net/manual/en/function.date.php.
<?php
// Assuming today is March 10th, 2001, 5:16:18 pm, and that we are in the
// Mountain Standard Time (MST) Time Zone
$today = date("F j, Y, g:i a"); // March 10, 2001, 5:16 pm
$today = date("m.d.y"); // 03.10.01
$today = date("j, n, Y"); // 10, 3, 2001
$today = date("Ymd"); // 20010310
$today = date('h-i-s, j-m-y, it is w Day'); // 05-16-18, 10-03-01, 1631 1618 6 Satpm01
$today = date('\i\t \i\s \t\h\e jS \d\a\y.'); // it is the 10th day.
$today = date("D M j G:i:s T Y"); // Sat Mar 10 17:16:18 MST 2001
$today = date('H:m:s \m \i\s\ \m\o\n\t\h'); // 17:03:18 m is month
$today = date("H:i:s"); // 17:16:18
?>
$current_date_num = date("Y-m-d H:i:s.u", time());
refer to http://php.net/manual/en/function.date.php
If you are trying to specify it in the page from user side
use it this way
strtotime($time1)