惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

T
The Blog of Author Tim Ferriss
IT之家
IT之家
Engineering at Meta
Engineering at Meta
WordPress大学
WordPress大学
博客园 - 三生石上(FineUI控件)
博客园 - 聂微东
C
Check Point Blog
T
Tailwind CSS Blog
博客园 - Franky
H
Help Net Security
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
Google DeepMind News
Google DeepMind News
博客园 - 叶小钗
J
Java Code Geeks
腾讯CDC
罗磊的独立博客
爱范儿
爱范儿
阮一峰的网络日志
阮一峰的网络日志
Martin Fowler
Martin Fowler
酷 壳 – CoolShell
酷 壳 – CoolShell
I
InfoQ
B
Blog
V
Visual Studio Blog
F
Fortinet All Blogs

博客园 - 五蕴非空

AI工具实践日记(二):在 OpenClaw 中调用 OpenCode 进行开发任务 AI工具实践日记(一):在树莓派上搭建OpenClaw,一个后端开发者的真实踩坑记录 .net core XML 解析帮助类 常用工具类 .net Core 同一接口不同实现的依赖注入 - 五蕴非空 大批量数据操作的性能优化方案 .net core 3.1 配置文件立即更新 为.net Core 3.0 WebApi 创建Linux守护进程 asp.net core 3.0 JObject The collection type 'Newtonsoft.Json.Linq.JObject' is not supported .net Core2.2 WebApi通过OAuth2.0实现微信登录 Asp.net导出Excel文件 Ext.Net 使用总结之GridPanel中的选中行 Ext.Net 使用总结之查询条件中的起始日期 Ext.Net 使用总结之GridPanel的删除事件 使用 NuGet 管理项目库 JavaScript 获取客户端计算机硬件及系统信息 程序员技术练级攻略 ThoughtWorks(中国)程序员读书雷达 Sql 分割 键值对字符串 得到某值对应的名称
Ext.net 中日期格式的计算
五蕴非空 · 2013-04-24 · via 博客园 - 五蕴非空

两个DateField控件,分别为开始时间和结束时间。当选择完结束时间后,自动计算这两个时间段所间隔的月或天数。

<ext:DateField runat="server" ID="extdate_start_date" LabelStyle=" text-align:right; " FieldLabel="开始时间" Vtype="daterange">
<CustomConfig>
    <ext:ConfigItem Name="endDateField" Value="#{extdate_end_date}" Mode="Value" />
</CustomConfig>
<Listeners>
      <Change Fn="GetBusiDay" />
</Listeners>
</ext:DateField>
<ext:DateField runat="server" ID="extdate_end_date" LabelStyle=" text-align:right; " FieldLabel="结束时间" Vtype="daterange">
     <CustomConfig>
          <ext:ConfigItem Name="startDateField" Value="#{extdate_start_date}" Mode="Value" />
     </CustomConfig>
      <Listeners>
          <Change Fn="GetBusiDay" />
      </Listeners>
</ext:DateField>

Js代码:

function GetBusiDay() {
            if (extdate_start_date.getValue() == "" || extdate_end_date.getValue() == "")
                return;
            var sday = Ext.util.Format.date(extdate_start_date.getValue(), 'Y/m/d');
            var eday = Ext.util.Format.date(extdate_end_date.getValue(), 'Y/m/d');
            var end = new Date(eday);
            var start = new Date(sday);

            var time = end.getTime() - start.getTime();
            var days = parseInt(time / (1000 * 60 * 60 * 24))+1;
            extnumb_busi_day.setValue(days);
        }

注意一定要转换日期格式 //日期格式为yyyy-mm-dd转换成yyyy/mm/dd