【问题标题】:ColdFusion Calendar - How can I find day from days in month?ColdFusion 日历 - 如何从一个月中的几天中找到日期?
【发布时间】:2011-02-25 21:21:54
【问题描述】:

这是我的代码。我是从在线教程中获得的。

<CFPARAM NAME = "month" DEFAULT = "#DatePart('m', Now())#" />
<CFPARAM NAME = "year" DEFAULT = "#DatePart('yyyy', Now())#" />
<CFPARAM NAME = "currentday" DEFAULT = "#DatePart('d', Now())#" />
<CFPARAM NAME = "startmonth" DEFAULT = "#DatePart('m', Now())#" />
<CFPARAM NAME = "startyear" DEFAULT = "#DatePart('yyyy', Now())#" />
<cfset ThisMonthYear = CreateDate(year, month, '1') />
<cfset Days = DaysInMonth(ThisMonthYear) />
<cfset LastMonthYear = DateAdd('m', -1, ThisMonthYear) />
<cfset LastMonth = DatePart('m', LastMonthYear) />
<cfset LastYear = DatePart('yyyy', LastMonthYear) />
<cfset NextMonthYear = DateAdd('m', 1, ThisMonthYear) />
<cfset NextMonth = DatePart('m', NextMonthYear) />
<cfset NextYear = DatePart('yyyy', NextMonthYear) />

这是我的输出代码。

<a href="calendar_day.cfm?month=#month#&day=#THE_DAY#&year=#year#">

我将其用于可见日历,并希望能够从该月的所有日期中选择日期。在月历视图中单击日期时,有什么方法可以确定月份中的哪一天?

【问题讨论】:

  • “确定月份中的哪一天”?什么意思?
  • 你的输出代码好像有点少
  • 问题不够清楚,无法回答。
  • 我和 Dan Short 在一起,我就是不明白。
  • 很抱歉给您带来了困惑。我想将 url 中的月份数字日期发送到另一个页面,以确定我在日历上选择的日期。

标签: date coldfusion calendar


【解决方案1】:

我相信您想要使用的是#URL.day#,以获取在 URL 中传递的日期变量,但正如大家所说,您的问题确实令人困惑。

【讨论】:

    【解决方案2】:

    正如所指出的,这个问题非常令人困惑。

    在月历视图中点击日期时,有什么方法可以确定月份中的哪一天?

    您在 Days var 中有该月的总天数。在日历渲染中,您可能会使用该 var 循环显示每月的每一天。您可以轻松地将该循环索引嵌入到生成的 HTML 中,以了解任何给定链接将引用的日期。

    <!--- loop thru all days in current month --->
    <cfloop from=1 to=Days index="this_day">
       <!--- display day in the calendar --->
       <a href="calendar_day.cfm?month=#month#&day=#this_day#&year=#year#">Day #this_day#</a>
       <cfif this_day eq CurrentDay>
            <!--- day being displayed is the current day, highlight it or whatever --->
       </cfif>
    </cfloop>
    

    【讨论】:

      猜你喜欢
      • 2010-12-13
      • 2021-12-09
      • 1970-01-01
      • 1970-01-01
      • 2021-12-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多