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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T11:34:00+00:00 2026-06-14T11:34:00+00:00

I have written some code where I get the modified time of a file

  • 0

I have written some code where I get the modified time of a file using

os.path.getmtime('path')

which returns some number like 965465464.19234. I convert it to bytes and send it over socket. At the other end I read the socket and try to set this timestamp to another file using:

os.utime('path',(access_time, modified_time))

I ensure access_time remains the same while I try to set the modified_time received from socket. But utime expects an integer, so I truncate the number (for example: 965465464) and then things work fine.

Am I losing any thing by truncating? How can this be made better?

  • 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-14T11:34:01+00:00Added an answer on June 14, 2026 at 11:34 am

    I don’t think that the problem has to do with modified_time being float or integer. The code below should work. I did everything, but send it over the wire.

    import os
    from datetime import datetime
    from calendar import timegm
    import sys
    st_info = os.stat('foo.py')
    st_info.st_atime #acces time
    st_info.st_mtime #modified time
    mtime = st_info.st_mtime
    atime = st_info.st_atime
    # send over the wire
    os.utime('foo.py', (atime, mtime))
    

    As you can see os.utime can do just fine with floats.

    mtime

    Out[15]: 1322517342.0

    In [16]: type(mtime)

    Out[16]: float

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

Sidebar

Related Questions

I have written some code using express.js which I'd like to put on the
Here I have written some code to get the square of a number from
I have written some code using jQuery to use Ajax to get data from
I have written some code which sends queries to google and returns the query
I have written some code that loads an XML document using an XmlDocument object
I have written some code in JSP to download .docx files which is hosted
I have written some code to look at properties using reflection. I have retrieved
I have written some code which produces simple animations based on cycling through a
I have written some simple code, to send en auto generated email, using the
I have written some code in Python using imapclient and poplib to collect my

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.