Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8921885
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T06:40:38+00:00 2026-06-15T06:40:38+00:00

I get some times from a database and I am trying to store them

  • 0

I get some times from a database and I am trying to store them by month, using the epoch form.
So I could have some random times like:

1354120744
1328978360
1297388332

and for each one I want to find the epoch value which represents the 1st of that month
so for the last timestamp it would be:

1296518400 (using lovely epochconverter.com).

I know that I can use POSIX mktime to reduce the timestamp down to days, mins etc and change them accordingly etc as was the answer to a post I did a while ago: How to go back months in Perl taking account of different days in month?

The trouble I have with that is that while I can zero times, I’m worried that by changing the date the day of week will not match up, so essentially making an invalid date. This may be an unnecessary worry; I don’t know if it would make a difference having the wrong day of week if the times are validated.

I couldn’t see any other POSIX methods which seemed useful. Any help appreciated!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T06:40:40+00:00Added an answer on June 15, 2026 at 6:40 am

    My first thought would be to use Time::Local to convert the localtime results back to epoch, with the appropriate values forced to 0 or 1 as needed. Note that day of week is not among the input values it expects, so you don’t need to worry about what happens if you get that wrong.

    $start_of_month_epoch = timelocal(0, 0, 0, 1, $month, $year);

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to store in a database some GPS data that I get from
I have been tackling this problem for some time. I get the image from
I have looked around for quite some time trying to get openCV installed. I'm
I have two JSPs where I am displaying some info from database in a
I am trying to parse a xml from some source and store the results
I want to get some data from some html pages that I have and
I get some datetime (ExactDate) from a db. These time are in US timezone,
After some time researching and trying different things I still cannot get my @ExceptionHandler
I'm trying to get some information about Azure blob (last modified UTC date time).
I'm using a QPainter to get some graphics on a window. Unfortunately every time

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.