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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T20:35:26+00:00 2026-06-11T20:35:26+00:00

So in my database I got a datetime field, filled with e.g. 2012-09-19 11:20:33.

  • 0

So in my database I got a datetime field, filled with e.g. 2012-09-19 11:20:33.
Now I’m trying to fetch the datetime.

$blabla = $something->getDatetime();

After that I create a new DateTime, which represents the time now

$now = new \DateTime("now");

And after that I want to subtract them like this (but it doesn’t work)?

$test1 = strtotime($blabla);
$test2 = strtotime($now);
$diff = $test2 - $test1; 
echo $diff;

My aim is to subtract the persisted datetime in the database from the time now…the result should be displayed in seconds…so 2012-09-19 11:22:22 – 2012-09-19 11:20:22 equals 120 (seconds).

I also tried to persist a unix timestamp into my database but unfortunately the field type timestamp doesn’t exist.

  • 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-11T20:35:27+00:00Added an answer on June 11, 2026 at 8:35 pm

    If you want the answer displayed in seconds, then just subtract the timestamps:-

    $blabla = $something->getDatetime();
    $now = new DateTime();
    $seconds = $now->getTimestamp() - $blabla->getTimestamp();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've got a database that maintains Jobs to be processed by various processing machines.
I'm now inserting a date/time data into my date/time field in the database. I
I got a application where I use DateTime.MaxValue to indicate that a entry have
I've got a table in a mysql database that contains monetary transactions. Let's say
I've got a form with a dropdownlist in my MVC app. Now that I'm
I've got a database that at the minute, I don't have access to directly,
I'm trying to filter database entries by their datetime: models.py: from django.db import models
In my database i got problem when converting varchar to datetime due to different
In my mySQL database I have a field called FlowerOpen that is in the
In a SQL database I got storage information for each user, for each customer.

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.