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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T03:31:42+00:00 2026-06-11T03:31:42+00:00

I need to pass datetimes between an android client, a python server and a

  • 0

I need to pass datetimes between an android client, a python server and a mysql server.

It should work the following:

  • the android client sends the exact time from the client to the cherrypy python server (I guess the datetime object should be sent as a string?)
  • the server has to parse this string into something useful to work with as a datetime object

Now there a two cases:

  1. the datetime object should be written into a mysql database (there is an attribute of type DATETIME in the related database table)
  2. the server should retrieve a datetime from the mysql database and compare it with the parsed datetime object

After some background processes finished their work with the python datetime objects as input parameters, a new datetime object should be passed back to the android client

Does anyone know some good solution for solving these problems?

  • 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-11T03:31:44+00:00Added an answer on June 11, 2026 at 3:31 am

    The best format for transferring datetime values is the ISO 8601 standard; they come in the format YYYY-mm-ddTHH:MM:SS+tz:tz, where the T is optional.

    Python’s datetime.datetime class can parse these with a simple extra module (see How to parse an ISO 8601-formatted date?). Output is just as easy with the .isoformat() method.

    MySQL’s DATETIME column type only deals with UTC values, but by default accepts ISO 8601 datetime strings (with a space instead of a T), so you’d have to cast your datetime objects to UTC (example with iso8601 module mentioned above):

    import iso8601
    utciso8601 = dt.astimezone(iso8601.iso8601.UTC).isoformat(' ')[:19]
    

    I’d insert the timezone offset into the database too; simply use the tzname() method to retrieve it from the datetime object, then parse it out again when loading from MySQL with the iso8601.iso8601.parse_timezone() function.

    # insertion:
    cursor.execute('INSERT INTO dates VALUES(?, ?)', utciso8601, dt.tzname())
    
    # querying
    for row in query:
        timezone = iso8601.iso8601.parse_timezone(row[1])
        utcdt = iso8601.parse_date(row[0])
        dt = utcdt.astimezone(timezone)
    

    I don’t know how well Android deals with dates and times, but surely it can handle ISO 8601 formats just fine.

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

Sidebar

Related Questions

I need to pass a variable which is captured from client side via jquery
I need to pass data to a variable in my master page each time
I have a SQL table where I need to work out the average time
So I have a flashobject which I need to pass a formatted DateTime string
I need to pass an extra parameter :mobilejs => true from jQuery to a
I need to pass argument to JNLP dynamically for which I tried using a
I need to pass Cursor object to another activity, what is the best way
I need to pass a parameter from an EditText and when I click the
I need to pass a simple Javascript array to my wcf ajax webservice: var
I need to pass a pointer through a scripting language which just has a

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.