PHP Print Date Print Format
So this should be a very simple question, but I can't seem to find a simple answer anywhere.
I am fixing some PHP code (I am not PHP'er) and I have this $ orderDate variable. How can I print this variable so that it's just M / d / yy h: mm tt?
Update: So I looked around and saw what $ orderDate is. Here's the code:
global $orderDate;
$orderDate = strftime('%c');
print("Order Date: ".date("M/d/Y h:M", $orderdate)."<br />");
so I get this for output:
Dec / 31/1969 06: Dec
and should get the date today ....
0
a source to share
4 answers
echo date("m/d/Y h:m", $orderDate);
echo date("m/d/Y h:m", strtotime($orderDate)); // or this
Depends on what $ orderDate contains.
Have a look at date () as it has a lot of examples and is pretty easy to use.
UPDATE:
$orderDate = date("M/d/Y h:M");
print("Order Date: ".orderDate ."<br />");
Also check if this works for you.
+7
a source to share