今天的日期格式-天(速记)日期编号月(速记)-PHP [英] Today's date format - Day (Shorthand) Date Number Month (Shorthand) - PHP

查看:100
本文介绍了今天的日期格式-天(速记)日期编号月(速记)-PHP的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个供稿,其提供的供稿格式如下: 10月14日星期五

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");

这将输出17 10。

什么是格式化$ today的最佳方法,以便它输出Day(简写)空格日期(数字)Month(简写)?

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

推荐答案

如何:

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

date()参考手册。

无论如何,除非您100%确信,否则应该注意时区问题

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.

我会采用不同的方法,但是您可以解析该Feed的使用 DateTime :: createFromFormat()的日期,它也了解时区,然后进行比较加上今天的日期。

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.

这篇关于今天的日期格式-天(速记)日期编号月(速记)-PHP的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆