{"id":28442962,"url":"https://github.com/mcxiaoke/espdatetime","last_synced_at":"2026-03-01T19:02:16.311Z","repository":{"id":37405860,"uuid":"224772323","full_name":"mcxiaoke/ESPDateTime","owner":"mcxiaoke","description":"Date Time Functions and Classes for ESP8266 and ESP32","archived":false,"fork":false,"pushed_at":"2021-04-17T10:54:09.000Z","size":233,"stargazers_count":49,"open_issues_count":4,"forks_count":10,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-06-29T11:38:17.277Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://blog.mcxiaoke.com/ESPDateTime/","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mcxiaoke.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-11-29T03:46:04.000Z","updated_at":"2024-12-04T02:01:21.000Z","dependencies_parsed_at":"2022-08-18T01:45:50.354Z","dependency_job_id":null,"html_url":"https://github.com/mcxiaoke/ESPDateTime","commit_stats":null,"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"purl":"pkg:github/mcxiaoke/ESPDateTime","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mcxiaoke%2FESPDateTime","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mcxiaoke%2FESPDateTime/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mcxiaoke%2FESPDateTime/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mcxiaoke%2FESPDateTime/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mcxiaoke","download_url":"https://codeload.github.com/mcxiaoke/ESPDateTime/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mcxiaoke%2FESPDateTime/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29980797,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-01T16:35:47.903Z","status":"ssl_error","status_checked_at":"2026-03-01T16:35:44.899Z","response_time":124,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-06-06T06:40:08.991Z","updated_at":"2026-03-01T19:02:16.296Z","avatar_url":"https://github.com/mcxiaoke.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ESPDateTime\n\nThis library provides a simple class `DateTimeClass` for sync system timestamp vis ntp and a struct `DateFormatter` to format date time to string, works on **ESP8266** and **ESP32** platform.\n\nCurrent Version: **v1.0.4** [![Build Status](https://travis-ci.org/mcxiaoke/ESPDateTime.svg?branch=master)](https://travis-ci.org/mcxiaoke/ESPDateTime)\n\n# Install\n\n## Using PlatformIO\n\nThis libarary is published to [PlatformIO](https://platformio.org/lib/show/6871/ESPDateTime), PlatformIO IDE has built-in PIO Home: Library Manager, you can search `ESPDateTime` in Library Manager and click to install this library.\n\nOr you can install using platformio cli:\n\n```bash\n# Using library Id\n platformio lib install 6871\n# or Using library Name\n pio lib install \"mcxiaoke/ESPDateTime@^1.0.4\"\n```\n\nAdd dependency to your `platformio.ini` file:\n\n```ini\nlib_deps =\n     # Using library Name\n     mcxiaoke/ESPDateTime @ ^1.0.4\n     # or You can use the latest git version\n     https://github.com/mcxiaoke/ESPDateTime.git\n```\n\n## Using Arduino IDE\n\nI will publish this library to Arduino Library soon. (TODO)\n\n## Manual Install\n\nClone this repo or download source code at [release](https://github.com/mcxiaoke/ESPDateTime/releases/latest) page, then copy all files in src to your project source directory.\n\n# Getting Started\n\n## Include the Header\n\n```cpp\n#include \u003cESPDateTime.h\u003e\n```\n\n## Config DateTime\n\n`DateTime` is a global [`DateTimeClass`](https://github.com/mcxiaoke/ESPDateTime/blob/master/src/DateTime.h#L58) object for use in your code.\n\nYou can pick `TimeZone` name from here: [TZ.h](https://github.com/esp8266/Arduino/blob/master/cores/esp8266/TZ.h) or here: [DateTimeTZ.h](https://github.com/mcxiaoke/ESPDateTime/blob/master/src/DateTimeTZ.h)\n\n```cpp\nvoid setupDateTime() {\n  // setup this after wifi connected\n  // you can use custom timeZone,server and timeout\n  // DateTime.setTimeZone(\"CST-8\");\n  // DateTime.setServer(\"asia.pool.ntp.org\");\n  // DateTime.begin(15 * 1000);\n  // from\n  /** changed from 0.2.x **/\n  DateTime.setTimeZone(\"CST-8\");\n  // this method config ntp and wait for time sync\n  // default timeout is 10 seconds\n  DateTime.begin(/* timeout param */);\n  if (!DateTime.isTimeValid()) {\n    Serial.println(\"Failed to get time from server.\");\n  }\n}\n```\n\n## DateTime Functions\n\nYou can use [`DateTime`](https://github.com/mcxiaoke/ESPDateTime/blob/master/src/DateTime.h#L58) to get current time and format time to string, `format` function internal using `strftime` function in `\u003ctime.h\u003e`.\n\n```cpp\n// alias for getTime()\ntime_t  DateTime.now()\n// get current timestap in seconds\ntime_t  DateTime.getTime()\n// get current timezone\nchar*     DateTime.getTimeZone()\n// get formatted string of time\nString  DateTime.toString()\n// get formatted string of utc time\nString  DateTime.toUTCString()\n// format local time to string, using strftime\n// http://www.cplusplus.com/reference/ctime/strftime/\nString  DateTime.format(const char* fmt);\n// format utc time to string, using strftime\n// http://www.cplusplus.com/reference/ctime/strftime/\nString  DateTime.formatUTC(const char* fmt);\n```\n\n## Classes\n\n- [**DateTimeClass**](https://github.com/mcxiaoke/ESPDateTime/blob/master/src/DateTime.h#L58) - Main Class for get current timestamp and format time to string, class of global `DateTime` object.\n- [**DateTimeParts**](https://github.com/mcxiaoke/ESPDateTime/blob/master/src/DateTime.h#L20) - Struct for get year/month/day/week part of time struct.\n- [**DateFormatter**](https://github.com/mcxiaoke/ESPDateTime/blob/master/src/DateTime.h#L44) - Class for format timestamp to string, include some format constants.\n- [**TimeElapsed**](https://github.com/mcxiaoke/ESPDateTime/blob/master/src/TimeElapsed.h) - Class for calculate elapsed time in milliseconds, original code is from [elapsedMillis](https://github.com/pfeerick/elapsedMillis).\n\n## Examples\n\nSee [examples](https://github.com/mcxiaoke/ESPDateTime/tree/master/examples/) folder in this project, to run example on your device, WiFi ssid and password must be set in source code.\n\n## Documents\n\nSee [API Reference](https://blog.mcxiaoke.com/ESPDateTime/).\n\n# License\n\n    Copyright 2019-2021 github@mcxiaoke.com\n\n    Licensed under the Apache License, Version 2.0 (the \"License\");\n    you may not use this file except in compliance with the License.\n    You may obtain a copy of the License at\n\n        http://www.apache.org/licenses/LICENSE-2.0\n\n    Unless required by applicable law or agreed to in writing, software\n    distributed under the License is distributed on an \"AS IS\" BASIS,\n    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n    See the License for the specific language governing permissions and\n    limitations under the License.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmcxiaoke%2Fespdatetime","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmcxiaoke%2Fespdatetime","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmcxiaoke%2Fespdatetime/lists"}