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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T22:38:22+00:00 2026-05-31T22:38:22+00:00

Probably I do something wrong but I can’t see the point of it ….

  • 0

Probably I do something wrong but I can’t see the point of it ….

Today is a one day of the week. I must know – how many days have elapsed from last monday to today?

$date_1d = date('Y-m-d', strtotime ('last Monday'));                     
// last monday

$date_today = date('Y-m-d');                                             
// actual date, today

$ile_dni = (strtotime($date_today) - strtotime($date_1d)) / (60*60*24);  
// difference in days - how many days have elapsed from today to last monday

I have 2 identical scripts as above in the same directory on the same server

first said:

&date_1d = > 2012-03-19

$date_today => 2012-03-26

strtotime($date_today) = > 1332720000

strtotime($date_1d) = > 1332115200

$ile_dni = > 7

second said:

&date_1d = > 2012-03-19

$date_today => 2012-03-26

strtotime($date_today) = > 1332712800

strtotime($date_1d) = > 1332111600

$ile_dni = > 6.9583333333333

Couse the right answer is the first. And what to do with this situation?

  • 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-31T22:38:23+00:00Added an answer on May 31, 2026 at 10:38 pm

    use ceil() on the $ile_dni the differences are from the timestamp generated out of ‘last Monday’ and strtotime and i’m sure there is a better way to do this with date('N'), you could do

    $ile_dni = date('N')-1; 
    

    if you wanted ile_dni to be 0 on monday, 1 on tuesday etc..

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

Sidebar

Related Questions

I know I'm probably just going something wrong, but I can't figure it out
I get the feeling this is probably something I should know but I can't
I can't see where I'm going wrong with the code below, its probably something
I know I am probably just doing something dumb wrong, but I need to
This is probably something really simple but I cant see what! Any images I
I know there is something wrong with the following reasoning but I'm not sure
Probably missing something pretty obvious but I can't figure out what is going on.
This is probably something extremely simple but I can't get my head around it
I realize it's probably something strange, but here is what I have. I have
This is probably something silly I'm missing but I'm definitely lost. I'm using .NET

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.