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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T19:29:06+00:00 2026-06-14T19:29:06+00:00

Ok so im trying to display a date that i got from a database

  • 0

Ok so im trying to display a date that i got from a database

Here’s what i can display without any formatting: 2012-11-21 19:00:00

what im trying to display is: 2012-11-21 at 19:00:00

below is the code

$expiryDate = date('Y/m/d', $data[0]->dinExpiry);
$expiryTime = date('H:i', $data[0]->dinExpiry);

And this is the error im getting;

enter image description here

Also the date that it displays is wrong

Thanks in advance 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-06-14T19:29:07+00:00Added an answer on June 14, 2026 at 7:29 pm

    Easy solution

    You say that you can display 2012-11-21 19:00:00 without any formatting.

    So if you can display an arbitrary $date as 2012-11-21 19:00:00, why not just substring it:

    $dateToDisplay = substr($date, 0, 11).'at '.substr($date, 11, 8);
    

    and show $dateToDisplay as 2012-11-21 at 19:00:00.

    A little more…

    It’s tricky to answer this without knowing the output of $data[0]->dinExpiry. (I’ll assume it gives you a variable called $date).

    As @Marc B says, the fact that you’re getting 1970 out of it shows that it’s not a valid timestamp (hint: it’s a string), so it’s evaluated to zero seconds since the Unix Epoch (January 1 1970 00:00:00 GMT).

    You can convert it to a valid timestamp like so:

    $expiryDate = date('Y-m-d', strtotime($date));
    

    Or to match your example:

    $expiryDate = date('Y-m-d', strtotime($data[0]->dinExpiry));
    $expiryTime = date('H:i', strtotime($data[0]->dinExpiry));
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to display information from a database in my android app. However,
I'm trying to display the expiry date of a bonus from within a Django
Hello I am trying to display work orders from my mysql database to show
I am trying to display the text from json in a list view. I
I have a problem with my XML that I am trying to display on
I am trying use Date Picker and on Select i want to display the
I'm trying to display set of data using jq grid. For that I used
I'm trying to use WebGrid HtmlHelper to display data from a few entities. The
I am trying to display a nullable date time in my JSON response. In
I was looking for a similar issue here at Stackoverflow javascript multiple date display

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.