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

Date validation is not working properly. If day = 90, month = 1 and
[{'date': '2010-04-01', 'people': 1047, 'hits': 4522}, {'date': '2010-04-03', 'people': 617, 'hits': 2582}, {'date': '2010-04-02',
ID Date Day Status 001 23/02/2009 Monday Appear 001 24/02/2009 Tuesday Appear 001 25/02/2009
var date = new Date();//Mon Mar 15 2010 12:40:05 GMT+0300 (MSK) var omg =
echo date(W,strtotime('2010-01-01')); This outputs 53. I would expect it to output 1. Can anyone
ID- DATE- NAME 10100- 2010/04/17- Name1 10100- 2010/04/14- Name2 10200- 2010/04/17- Name3 10200- 2010/04/16-
Table1 Date id salary 01/2012 001 1500 01/2011 001 750 01/2010 001 500 from
date value 18/5/2010, 1 pm 40 18/5/2010, 2 pm 20 18/5/2010, 3 pm 60
I have a date in this string format 02/28/2012 and I want to convert
date(m); returns the following result for this month... 02 That is fine and dandy,

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.