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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T19:37:31+00:00 2026-06-18T19:37:31+00:00

im trying to get the first day of a given week based on inputting

  • 0

im trying to get the first day of a given week based on inputting a week number and year. im currently using this for the current week and year and works like a charm.

$week = date('W');
$year = date('Y');
$date1 = date('Y-m-d', strtotime($year."W".$week.'1'));

however when i try to input my own week and year it doesn’t work

$week = 7;
$year = 2013;
$date1 = date('Y-m-d', strtotime($year."W".$week.'1'));

what type if string should i be using for strtotime? how come providing my own date doesn’t work?

  • 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-18T19:37:33+00:00Added an answer on June 18, 2026 at 7:37 pm

    Because the week numbers are supposed to be padded (and the extra 1 at the end doesn’t really do anything):

    $date1 = date(
        'Y-m-d', 
        strtotime($year . 'W' . str_pad($week, 2, '0', STR_PAD_LEFT))
    );
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to get the timestamp of the first day of the month
I am trying to get my first button to update a display number in
I am trying to get the names of all first level directories under given
I'm trying to get the first and last day of the previous month. What
I have spent the entire day trying to get this code snippet to work:
I'm trying to get the dates of monday-thursday in the current week. But for
I'm trying to get the first day of the next quartal, for example now
It is my first day and I'm trying to get a simple even workign
This is my first shot at writing a stored procedure. I'm trying to get
I'm trying to figure out how can I get the the first day of

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.