www.webdeveloper.com
Results 1 to 4 of 4

Thread: how to add a dash between a number

  1. #1
    Join Date
    Apr 2013
    Posts
    2

    Red face how to add a dash between a number

    actually i have a number that is generated from a database.
    like $clo_date = 20130405
    what i need is to make that number as 2013-04-05

    so how can i do it in php

  2. #2
    Join Date
    Dec 2012
    Posts
    97
    You could format it using the date function

    PHP Code:
    $date date("Y-m-d",strtotime($clo_date));
    echo 
    $date

  3. #3
    Join Date
    Mar 2011
    Posts
    1,138
    Or you could use a regular expression:
    Code:
    preg_match('/(\d{4})(\d{2})(\d{2})/', $clo_date, $matches);
    $clo_date = implode('-', $matches);
    Rick Trethewey
    Rainbo Design

  4. #4
    Join Date
    Apr 2013
    Posts
    2
    thank you allll

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles