Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I use words in PHP date format? [duplicate]

Tags:

php

I want to use PHP date to write something like:

Generated Fri, Aug 30, 2013 at 1:00pm

using:

echo "Generated ".date('D, M j, Y at g:ia');

However, I cannot use the "at" because that is swapped with 00am

Is there a way to include the word at in the date formation without using two date()?

like image 791
danielb Avatar asked Aug 30 '13 13:08

danielb


People also ask

How can I get current date in YYYY MM DD format in PHP?

date_default_timezone_set('UTC'); echo "<strong>Display current date dd/mm/yyyy format </strong>". "<br />"; echo date("d/m/Y"). "<br />"; echo "<strong>Display current date mm/dd/yyyy format</strong> "."<br />"; echo date("m/d/Y")."<br />"; echo "<strong>Display current date mm-dd-yyyy format </strong>".

What is Z in date format PHP?

Z - Timezone offset in seconds. The offset for timezones west of UTC is negative (-43200 to 50400) c - The ISO-8601 date (e.g. 2013-05-05T16:34:42+00:00) r - The RFC 2822 formatted date (e.g. Fri, 12 Apr 2013 12:01:05 +0200)

Which PHP function do you use to format date information?

The date_format() function returns a date formatted according to the specified format.

How can I timestamp in PHP?

The task can be done by using the strtotime() function in PHP. It is used to convert English textual date-time description to a UNIX timestamp.


1 Answers

You can escape characters in the output like this:

echo "Generated ".date('D, M j, Y \a\t g:ia');

The following is taken from the PHP Date function (http://php.net/manual/en/function.date.php):

<?php
// prints something like: Wednesday the 15th
echo date('l \t\h\e jS');
?>
like image 164
Fluffeh Avatar answered Nov 11 '22 14:11

Fluffeh