> For the complete documentation index, see [llms.txt](https://docs.zongsoft.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.zongsoft.com/documentation/en/framework/core/common/timestamp.md).

# Timestamp

Understand epoch and elapsed time in Discussions attachment names.

Timestamp calculates a point in time or elapsed time in the specified epoch. Discussions' attachment uploads use the cumulative number of days in the Millennium epoch as part of the filename, combined with a random suffix.

Source: [src/api/Controllers/FileController.cs](https://github.com/Zongsoft/Zongsoft.Discussions/blob/main/src/api/Controllers/FileController.cs#L79) (excerpt; see source for context).

{% code title="FileController.cs" %}

```csharp
var infos = this.Accessor.Write(this.Request,
							  this.DataService.GetDirectory(id),
							  args => args.FileName = $"{Timestamp.Millennium.Epoch.GetElapsed().Days}-{Randomizer.GenerateString()}", cancellation);
```

{% endcode %}

This code is in UploadAsync: Request comes from the current HTTP request, the directory is determined by the FileService, and cancellation comes from the caller. It does not treat the number of days in the file name as a business primary key or access permission.

## Epoch, Units and Time Zone

Unix and Millennium are different starting points. When passing time values across systems, both the starting point and the unit must be agreed upon; simply passing a number is not enough to determine whether it represents seconds, milliseconds, days, or ticks. Time zone presentation should also be distinguished from persistence time conventions.

## The Difference with Business Audit Time

Audit fields like CreatedTime, ModifiedTime, etc. of Discussions are filled in by DataValidator using DateTime.Now. The attachment name uses the epoch day, which does not mean that the entire module has uniformly adopted Unix timestamps. See [Data Services](/documentation/en/framework/data/services.md) for audit strategy.

Methods and boundaries can be checked for [Timestamp source code](https://github.com/Zongsoft/framework/blob/main/Zongsoft.Core/src/Common/Timestamp.cs) and [Correspondence test](https://github.com/Zongsoft/framework/blob/main/Zongsoft.Core/src/Common/Timestamp.cs).


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.zongsoft.com/documentation/en/framework/core/common/timestamp.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
