When creating a DateTime object with a unix timestamp, why does a '@' symbol need to precede the time stamp?
The date() function formats a local date and time, and returns the formatted date string.
A few examples of creating DateTime objects with valid time string: $yesterday = new DateTime('yesterday'); $twoDaysLater = new DateTime('+ 2 days'); $oneWeekEarly = new DateTime('- 1 week'); The second parameter of the DateTime's constructor allows us to specify a timezone.
As far as I know it is so that the timestamp can be identified from other valid formats.
http://www.php.net/manual/en/datetime.formats.php
unix timestamp is under the compound formats.
It's been quite long since the question is asked, but if anyone still looking for the answer and landed on this question. Then here's it is.
echo date("dS M Y \\@\\ g:ia");
// 18th Jun 2020 @ 4:20pm
echo date("dS M Y \\a\\t g:ia");
// 18th Jun 2020 at 4:20pm
echo date("dS M Y \\a\\n\\d g:ia");
// 18th Jun 2020 and 4:20pm
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With