# 如何验证小红书发布日期筛选跨北京时间午夜

[规范网址](https://social2api.com/guides/rednote-utc-midnight-boundary/)

先转为 UTC+08:00，再检查是否落在起止日；UTC 16:00 对应北京时间次日零点。

## Agent 提示词

~~~~text
请在 Social2api 使用小红书笔记搜索 API，执行以下任务。
目标：将带时区时间戳换算成北京时间自然日。
输入与对照示例：午夜边界测试对。`2026-01-14T15:59:59Z` 算 1 月 14 日，`2026-01-14T16:00:00Z` 算 1 月 15 日。仅筛 15 日时后一条入窗。
公开查询可先用免密钥合成示例；实时取数需要权限和部署支持。
按以下步骤完成：调用小红书搜索 API 并保留带时区的 publishedAt 原值 以 UTC+08:00 派生自然日列 用临界日前后的两条合法样本复算是否应入窗
交付能核对的结果和必要字段：publishedAt、北京时间日期、查询起始日、查询结束日。注明来源或限制，并以本页为操作参考。
https://social2api.com/guides/rednote-utc-midnight-boundary/
~~~~

[查看小红书搜索接口](https://social2api.com/docs/api/rednote-notes-search/)

## 本页用到的 Social2api 接口

| 接口与参数文档 | 用途 |
| --- | --- |
| [小红书公开笔记搜索](https://social2api.com/docs/api/rednote-notes-search/) · POST /api/run · task=rednote | 按关键词搜索公开笔记，并可用发布日期和结果条数收窄范围。 |

## 在 Social2api 使用小红书笔记搜索 API

1. 调用小红书搜索 API 并保留带时区的 publishedAt 原值
2. 以 UTC+08:00 派生自然日列
3. 用临界日前后的两条合法样本复算是否应入窗

## 复制请求并试跑

请求一个北京时间自然日来核对参数与日期列，带时区的午夜边界由本地换算样例单独测试。

这条请求使用合成样例，免登录、免 API Key，上游请求数为 0。要查真实数据，将 mode 改为 live，换成实际输入，并在 Authorization 中提供有相应任务权限的 Bearer API Key。可用 maxRequests 限制实时上游请求数。

~~~~bash
curl --fail-with-body -sS 'https://social2api.com/api/run' \
  -H 'Content-Type: application/json' \
  --data-binary @- <<'JSON'
{
  "task": "rednote",
  "mode": "demo",
  "params": {
    "query": "城市骑行",
    "limit": 4,
    "since": "2026-01-15",
    "until": "2026-01-15"
  }
}
JSON
~~~~

## 用两个带时区的时间戳核对跨午夜

托管 demo 返回日粒度示例，只用来核对字段。下面用离线固定值复算北京时间 1 月 15 日的起点。真实响应若只给日期，保留原日期和数据源，不能从中复原午夜前后的具体时分秒。

~~~~python
from datetime import date, datetime
from zoneinfo import ZoneInfo

samples = ['2026-01-14T15:59:59Z', '2026-01-14T16:00:00Z', '2026-01-15', None]
report_day = date(2026, 1, 15)
china = ZoneInfo('Asia/Shanghai')

def china_date(value):
    if not value or len(value) == 10:
        return None
    timestamp = datetime.fromisoformat(value.replace('Z', '+00:00'))
    return timestamp.astimezone(china).date() if timestamp.tzinfo else None

converted = [china_date(value) for value in samples]
assert converted == [date(2026, 1, 14), report_day, None, None]
print([value for value in samples if china_date(value) == report_day])
~~~~

## 操作示例与核对

午夜边界测试对。`2026-01-14T15:59:59Z` 算 1 月 14 日，`2026-01-14T16:00:00Z` 算 1 月 15 日。仅筛 15 日时后一条入窗。

## 需要核对的字段

publishedAt、北京时间日期、查询起始日、查询结束日。

## 接口文档

- [小红书公开笔记搜索](https://social2api.com/docs/api/rednote-notes-search/)

## 相关用户讨论

- [用户讨论 · 小红书 · 怎样按年份检索小红书旧笔记？](https://www.reddit.com/r/rednote/comments/1swwej6/search_posts_from_2018/)
- [相邻平台类比 · YouTube · I've been searching for a way to filter youtube by date range, anyone know a way?](https://www.reddit.com/r/answers/comments/p8cjfd/ive_been_searching_for_a_way_to_filter_youtube_by/)

## 相关指南和问答

- [如何按关键词搜索小红书笔记并导出 CSV](https://social2api.com/guides/xiaohongshu-keyword-search-export/)

[查看小红书搜索接口](https://social2api.com/docs/api/rednote-notes-search/)
