# Set last modified out header

**URL:** <https://www.ruby-forum.com/t/set-last-modified-out-header/244036>\
**Category:** NGINX\
**Created:** [February 10, 2016, 9:44am UTC](https://www.ruby-forum.com/t/set-last-modified-out-header/244036 "2016-02-10T09:44:39Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Rafa\_F](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/958977/32.png) [@Rafa\_F](https://www.ruby-forum.com/u/Rafa_F)\
**Post date:** [February 10, 2016, 9:44am UTC](https://www.ruby-forum.com/t/set-last-modified-out-header/244036/1 "2016-02-10T09:44:39Z")

</div>

Hello,  
I am building my own NGINX module, when I try to set the last modified  
out  
header I have a struct timespec which I need to convert to last  
modified.  
When I set the last modified with the tv\_sec the last modified get  
invalid  
date.

How can I set the last modified correctly?

Posted at Nginx Forum:

> **[Set last modified out header](https://forum.nginx.org/read.php?2,264458,264458#msg-264458)**
>
> Hello, I am building my own NGINX module, when I try to set the last modified out header I have a struct timespec which I need to convert to last modified. When I set the last modified with the tv\_sec the last modified get invalid date. How can I set...

---

<div class="post-metadata">

**Author:** ![Ortal](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/o/8491ac/32.png) [@Ortal](https://www.ruby-forum.com/u/Ortal)\
**Post date:** [February 10, 2016, 2:16pm UTC](https://www.ruby-forum.com/t/set-last-modified-out-header/244036/2 "2016-02-10T14:16:17Z")

</div>

Hello!

On Wed, Feb 10, 2016 at 03:44:13AM -0500, Ortal wrote:

> Hello,  
> I am building my own NGINX module, when I try to set the last modified out  
> header I have a struct timespec which I need to convert to last modified.  
> When I set the last modified with the tv\_sec the last modified get invalid  
> date.
> 
> How can I set the last modified correctly?

The “struct timespec” is not guaranteed to contain time since any  
specific point in the past. So the question is: how did you got  
the struct timespec?

E.g., when using clock\_gettime(CLOCK\_REALTIME), tv\_sec is expected  
to contain seconds since the Epoch, and it should work fine. But  
when using clock\_gettime(CLOCK\_MONOTONIC) tv\_sec is “since an  
unspecified point in the past” (quoting POSIX, see [1]), and it’s  
not possible to convert it to time since the Epoch as required by  
r-\>headers\_out.last\_modified\_time.

[1]

> **[clock\_getres](https://pubs.opengroup.org/onlinepubs/9699919799/functions/clock_gettime.html)**

–  
Maxim D.

> **[nginx](http://nginx.org/)**
