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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T19:01:31+00:00 2026-05-17T19:01:31+00:00

$date =’20101015′; how to convert to $year = 2010 , $month = 10 ,

  • 0
$date ='20101015';

how to convert to $year = 2010,$month = 10, $day =15

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-17T19:01:32+00:00Added an answer on May 17, 2026 at 7:01 pm

    You can use the PHP substring function substr as:

    $year  = substr($date,0,4);  # extract 4 char starting at position 0.
    $month = substr($date,4,2);  # extract 2 char starting at position 4.
    $day   = substr($date,6);    # extract all char starting at position 6 till end.
    

    If your original string as leading or trailing spaces this would fail, so its better feed substr trimmed input as. So before you call substr you can do:

    $date = trim($date);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Given a date/time as an array of (year, month, day, hour, minute, second), how
Date validation is not working properly. If day = 90, month = 1 and
Date.toLocaleString() returns this in Chrome: Mon Jan 18 2010 16:47:42 GMT+1100 (AUS Eastern Daylight
[{'date': '2010-04-01', 'people': 1047, 'hits': 4522}, {'date': '2010-04-03', 'people': 617, 'hits': 2582}, {'date': '2010-04-02',
date value 18/5/2010, 1 pm 40 18/5/2010, 2 pm 20 18/5/2010, 3 pm 60
Date Array array( 0 => array(date_1 => 06-09-2010), 1 => array(date_2 => 07-09-2010), 2
[NSDate date]in iOS 4.0 used to return date in the format: 2010-09-15 09:28:26 +0530
I want to create date with specific format for e.g 03-20-2010 have a format
Date Starting Ending 10/01/2010 0 100 10/02/2010 100 200 10/03/2010 200 300 10/04/2010 300
Date: Sun, 31 Oct 2010 21:12:24 +0600 From: jim@google.com X-Priority: 3 (Normal) Message-ID: <1176875350.20101031211224@goole.com>

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.