Today's date format - Day (Shorthand) Date Num

2019-07-26 23:15发布

I have a feed which gives feed in the following format: "Fri 14 Oct"

I want to see if today's date matches the date from the feed. My problem is the format of today's date/

  $today = date("d m");

This outputs 17 10.

What is the best way to format $today so that it outputs Day (shorthand) space date (number) Month (shorthand) ?

3条回答
冷血范
2楼-- · 2019-07-26 23:52

how about:

$today = date("D j M");

As explained in date() reference manual.

Anyway you should be aware of timezone issues unless you are 100% sure that your server is in the same timezone of the feed you are comparing.

I would follow a different approach though, you can parse the feed's date using DateTime::createFromFormat() which also understand timezones, and then compare it with today's date.

查看更多
smile是对你的礼貌
3楼-- · 2019-07-26 23:58
<?php
// Prints the day
echo date("l") . "<br>";

// Prints the day, date, month, year, time, AM or PM
echo date("l jS \of F Y h:i:s A");
?>

For more details, please visit http://www.w3schools.com/php/func_date_date.asp

查看更多
贪生不怕死
4楼-- · 2019-07-27 00:02
$today = date("D d M");

PHP Date Documentation

查看更多
登录 后发表回答