1、lecms时间戳转换教程

先用一个 标签 获取原来网站的发布时间,在建一个time标签,对获取到的那个标签,数据处理就好了,然后在发布模块增加字段 dateline字段,

火车头发布参考文章:https://www.lecms.cc/index.php?thread-55.htm

代码如下

using System;
using System.Collections.Generic;
using SpiderInterface;
class LocoyCode{
    ///
    /// 执行方法,不能修改类和方法名称。
    /// 
/// 标签内容 /// 页面响应,包含了Url、原始Html等属性 /// 返回处理后的标签内容 public string Run(string content,ResponseEntry response){ // 在这里编写处理代码 string dt = "yyyy-MM-dd"; DateTime time = DateTime.ParseExact(content, dt, System.Globalization.CultureInfo.CurrentCulture); DateTime startTime = TimeZone.CurrentTimeZone.ToLocalTime(new DateTime(1970, 1, 1)); // 这里除10000000将时间戳调整为10位,如果要保留13位,那么将 10000000 改为 10000 long t = (time.Ticks - startTime.Ticks) / 10000000; content = t.ToString(); return content; } }

2、火车头采集时间与时间戳互转的c#语法
时间戳转换为时间 源代码:


using System;
using System.Collections.Generic;
using SpiderInterface;
class LocoyCode{
/// 执行方法,不能修改类和方法名称。 ///

///标签内容 ///页面响应,包含了Url、原始Html等属性 /// 返回处理后的标签内容 public string Run(string content,ResponseEntry response){ // 在这里编写处理代码 DateTime dateTimeStart = TimeZone.CurrentTimeZone.ToLocalTime(new DateTime(1970, 1, 1)); // 时间戳默认为10位,如果是13位,那么需要将下面的 0000000 改为 0000 long lTime = long.Parse(content + "0000000"); TimeSpan toNow = new TimeSpan(lTime); DateTime newTime = dateTimeStart.Add(toNow); content = newTime.ToString("yyyy-MM-dd HH:mm:ss"); return content; } }

时间转换为时间戳源代码:


using System;
using System.Collections.Generic;
using SpiderInterface;
class LocoyCode{
/// 执行方法,不能修改类和方法名称。 ///

///标签内容 ///页面响应,包含了Url、原始Html等属性 /// 返回处理后的标签内容 public string Run(string content,ResponseEntry response){ // 在这里编写处理代码 string dt = "yyyy-MM-dd HH:mm:ss"; DateTime time = DateTime.ParseExact(content, dt, System.Globalization.CultureInfo.CurrentCulture); DateTime startTime = TimeZone.CurrentTimeZone.ToLocalTime(new DateTime(1970, 1, 1)); // 这里除10000000将时间戳调整为10位,如果要保留13位,那么将 10000000 改为 10000 long t = (time.Ticks - startTime.Ticks) / 10000000; content = t.ToString(); return content; } }
特别声明:本站所有资源均为学习测试使用,请在下载后48小时之内自主删除,本站以学习为目的不承担任何法律责任!