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

  • Home
  • SEARCH
  • 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 6346095
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T20:57:08+00:00 2026-05-24T20:57:08+00:00

I was wondering, if I record a time through a javascript function and say

  • 0

I was wondering, if I record a time through a javascript function and say I leave it on for 2 mins 20 seconds:

00.02.20

now when I insert this into my database, where the field type is set as time, it doesn’t record properly.

I think it comes from how I request the data:

$length = mysql_escape_string($_REQUEST['timeDrive']);

is there a way of converting this into a time that is going to output the exact value:

00.02.20

thanks for the help!

  • 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-24T20:57:10+00:00Added an answer on May 24, 2026 at 8:57 pm

    If you don’t need to perform any mathematical functions on those fields (eg: sum, average, etc), and it’s purely for display, then you can just store it as plain text in a CHAR(8) field.

    Otherwise, you’ll need to normalise it to some sort of unit. I’d suggest maybe as an integer of the total number of seconds (if that is accurate enough for you).

    To convert to seconds:

     $val = "00.02.20";
     $parts = explode(".", $val);   // ['00', '02', '20']
     $totalSeconds = parts[0] * 3600 + parts[1] * 60 + parts[2]; // 140
    

    And to convert it back:

    $seconds = 140; // this would be read from the database, or something
    
    printf("%02d.%02d.%02d",
        $seconds / 3600,
        ($seconds / 60) % 60,
        $seconds % 60
    );
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm wondering if it's worth the server time when updating a record to retrieve
I am wondering what happens if I lazy load Google Analytics JavaScript few seconds
I was wondering if its ok to edit the created_at value of a record
I want to retrieve the most recently added record from CoreData. I was wondering
Wondering if anyone has gotten the infamous database is locked error from Trac and
Wondering how to open many new windows with Javascript. I have found plenty of
Wondering if anyone can help me with this annoying but trivial (in terms of
I am wondering how can do a mass insert and bulk copy at the
I am wondering if there is a way to specify a php function or
I'm experimenting with fopen for the first time and was wondering if it was

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.