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 7669479
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T15:36:15+00:00 2026-05-31T15:36:15+00:00

Can someone help me understand why I get -1 returned by mktime in the

  • 0

Can someone help me understand why I get “-1” returned by mktime in the following code. Thanks.

#!/usr/local/bin/bash
f_name="crap.stat"
S_Date="2012-02-10"
E_Date="2012-02-13"

gawk -F '\t' -v s_date="$S_Date" -v e_date="$E_Date" 'BEGIN {s_time = mktime(s_date);e_time = mktime(e_date);print s_time, e_time}' $f_name
  • 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-05-31T15:36:16+00:00Added an answer on May 31, 2026 at 3:36 pm

    You have to use a specific format for that function. Here your code fixed:

    #!/usr/local/bin/bash
    f_name="crap.stat"
    S_Date="2012-02-10"
    E_Date="2012-02-13"
    
    gawk -F '\t' -v s_date="$S_Date" -v e_date="$E_Date" '
      BEGIN { 
        gsub( /-/, " ", s_date ); 
        s_date = s_date " " 00 " " 00 " " 00; 
        s_time = mktime(s_date);
        gsub( /-/, " ", e_date ); 
        e_date = e_date " " 00 " " 00 " " 00;
        e_time = mktime(e_date);
        print s_time, e_time
      }
    ' $f_name
    

    Result:

    1328828400 1329087600
    

    It must be next format: YYYY MM DD HH MM SS[ DST], so I replace - with spaces and append zeros for the time.

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

Sidebar

Related Questions

Can someone please help me understand the following: In the previous version of NHibernate
Can someone help me understand why the following query is not offsetting correctly? It's
(Specifically, I'm using Backbone Model events) Can someone help me understand how javascript events
Can someone help me figure out the following make file? BINS=file1 file2 file3 all:
Can someone help explain the following: If I type: a=`ls -l` Then the output
Can someone help me with the getopt function? When I do the following in
can someone help with this? I need the following function to do this... $x
can someone help me understand this because it's working in as3 but not so
Can someone help me understand how best to model a composition relationship? If for
Can someone help me understand variable/function inheritance in PHP classes. My parent class has

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.