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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T00:59:12+00:00 2026-05-20T00:59:12+00:00

I have a date formatted like this: 2011-15 The first piece is a 4

  • 0

I have a date formatted like this:

2011-15

The first piece is a 4 digit year and the second piece is the day of the year since January 1.

According to php.net docs I should be able to do something like

$date = date_create_from_format('Y-z', '2011-15');
echo $date->format('Y-m-d');

and get the date returned in a more sane value.

This, however, doesn’t work at all. It causes php to reset the connection.

Is there a better way to turn “day of the year” into a more usable value (i.e. month and day)

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-05-20T00:59:12+00:00Added an answer on May 20, 2026 at 12:59 am

    To accomplish your goal in older versions of php you can use something like the following:

    <?php
        $date_string = '2011-15';
        $date_array = preg_split('/-/',$date_string);
    
        $start_of_year = strtotime("1 January {$date_array[0]}");
        $date = strtotime("+".($date_array[1]-1)." days", $start_of_year);
        echo "$date \n";
        echo date("Y-m-d",$date);
    ?>
    

    Which outputs:
    1295074800
    2011-01-15

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

Sidebar

Related Questions

I have a date field in a mysql table formatted like this: Y-m-d. I
I have date objects formatted like 2011/06/13 17:52:20 and being returned as strings. How
I have a date/time string like this: 180510_112440 in this format ddmmyy_hhmmss I need
I have a REST URL to get all users formatted like this: http://example.com/users To
In my db, I have a column for date (formatted as 3-1-2011) and a
I have an array that is formatted like so (this example has 5 keys):
I have methods in all of my models that look like this: def formatted_start_date
I have start date and end date. I need to find out the day
I have weather forecast data formatted like so: loc_id#location#state#forecast_date#issue_date#issue_time#min_0#max_0#min_1#max_1#min_2#max_2#min_3#max_3#min_4#max_4#min_5#max_5#min_6#max_6#min_7#max_7#forecast_0#forecast_1#forecast_2#forecast_3#forecast_4#forecast_5#forecast_6#forecast_7# 090180#Airey's Inlet#VIC#20091204#20091204#161830###12#19#12#21#12#19#12#17#11#20#12#20#11#17#Mostly clear.#Shower or two.#Light
Right now my dates look like this: `2011-01-01 5:45:23 +0000 I want them to

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.