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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T20:50:19+00:00 2026-06-10T20:50:19+00:00

I have a code but can’t find where is an error. I have upcoming

  • 0

I have a code but can’t find where is an error. I have upcoming event and current time. If I convert my event to the timestamp it’s less then current timestamp. May be you can help me.

My code below:

<?php

date_default_timezone_set('Etc/GMT');

$upcoming       = "2012.09.05 23:50";
$current        = time();

echo "Upcoming: " . $upcoming . " | Timestamp:" .  mktime(23, 50, 0, 09, 05, intval(date("Y")));
echo "<br>Current: " . time();
echo "<br>Current SIM: " .  mktime(date("H"), date("i"), date("s"), date("m"), date("d"), date("Y"));


?>

Will output:

Upcoming: 2012.09.05 23:50 | Timestamp:1323129000
Current: 1346855221
Current SIM: 1346855220

Where Current > Upcoming timestamp. (???)
Thanks!

  • 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-10T20:50:20+00:00Added an answer on June 10, 2026 at 8:50 pm

    Because you have 09 (with a preceding 0) this number is interpreted as an octal number, and so it’s converted to 0.
    Use: mktime(23, 50, 0, 9, 5, intval(date("Y")));

    You can explore this “feature” a bit;

    var_dump(9);   // int 9
    var_dump(09);  // int 0
    var_dump(07);  // int 7
    var_dump(17);  // int 17
    var_dump(017); // int 15
    

    EDIT;

    date('n'); returns the month without leading zeros. And date('j'); and date('G'); return the day and hour without leading zeros. So you can change mktime(date("H"), date("i"), date("s"), date("m"), date("d"), date("Y")); to mktime(date("G"), date("i"), date("s"), date("n"), date("j"), date("Y"));

    There’s no way to get the number of minutes and seconds without leading zeros with date() so maybe you need to find another function for that.

    EDIT:

    To convert 2012.09.05 23:50 to a timestamp you can change the . to / and feed it to strtotime():

    $str = '2012.09.05 23:50';
    $str = str_replace(".", "/", $str);
    $timestamp = strtotime($str);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have searched but can't find why this simple code will fail in Drools
I have android.permission.READ_OWNER_DATA but I can't find any reliable code that would explain how
I have been working on this code but I can't find out what is
I have code that generates a List<string[]> variable but can't quite figure out how
i have following code for moving 4 picture around circular way,but it can rotate
I have this code to update users data, but I can't write the for
I have the following code, but I can't get it to work. As soon
I have read my code again and again, but I can't figure out whats
I have the following code to do this, but how can I do it
I have seen this code documented in the tk docs, but I can't figure

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.