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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T14:14:47+00:00 2026-05-27T14:14:47+00:00

Problem with Date function output: 00:00am on Sunday December 17th, 2011 Problem hour and

  • 0

Problem with Date function

output: 00:00am on Sunday December 17th, 2011

Problem
hour and minutes always display 00:00 and sometime Year is also incorrect

Input
date(‘Y-m-d H:i:s’, time());

functions

public function perfect_date_format($date) {
    $dated = str_replace(array(" ", ":"), "-", $date);
    list($year, $month, $day, $hour, $minute) = explode("-", $date);
    $niceday = @date("H:ia \o\\n\ l, F jS, Y", mktime($hour, $minute, 0, $month, $day, $year));
    return $niceday;
  }
  • 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-27T14:14:48+00:00Added an answer on May 27, 2026 at 2:14 pm

    You have a typo. The 2nd argument to explode() should be $dated, rather than $date. If you do this, the time is correctly displayed.

    <?php
    function perfect_date_format($date) {
        $dated = str_replace(array(" ", ":"), "-", $date);
        list($year, $month, $day, $hour, $minute) = explode("-", $dated);
        $niceday = @date("H:ia \o\\n\ l, F jS, Y", mktime($hour, $minute, 0, $month, $day, $year));
        return $niceday;
    }
    
    echo perfect_date_format('2011-12-17 03:45:00') . "\n";
    ?>
    

    This outputs:

    03:45am on Saturday, December 17th, 2011
    

    BTW: It’s safe to remove the error suppressor operator (ie. @) in the code above. It was simply suppressing errors or warnings caused by the bug identified above. Now that the bug is fixed, the @ isn’t doing anything.

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

Sidebar

Related Questions

I have a bizzare problem with php date function. code: $numDays = 8; $date
This is output from a mysql export function. Problem is I don't know the
With reference to Problem with date day/month reversing on save I have further noted
I have a weird date rounding problem that hopefully someone can solve. My client
I'm currently wrestling with an Oracle SQL DATE conversion problem using iBATIS from Java.
My problem is that I receive for example a date in a concatenated format:
Main problem: how do i group elements by their Date, only if continuous and
i have one problem when i sort the NSMutablearray using date and time wise.
I am using DateTimePicker with Australian date formatting set (dd/mm/yyyy) The problem is when
I've got a typical problem when trying to insert a date into MySQL. The

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.