Results 1 to 3 of 3

Thread: [RESOLVED] regex date time from string

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Aug 2007
    Posts
    912

    Resolved [RESOLVED] regex date time from string

    i have string that contain time and date.. But this string can have anything and can have date and time anywhere in the string...

    How can i get date and time only in such cases?

    Example string is here
    Code:
    Your product was delivered at 10:41 am on July 21, 2015 in sydney, Xw 3235.
    i need following from above string

    10:41 am

    July 21, 2015

    it can have any date and time

  2. #2
    Freelancer akhileshbc's Avatar
    Join Date
    Jun 2008
    Location
    Trivandrum, Kerala, India
    Posts
    7,650

    Re: regex date time from string

    Maybe something like this will help?

    Code:
    \s(\d{2}:\d{2}\s[a-z]{2}).*\s([a-zA-Z]*\s\d{2},\s\d{4})
    Live url for testing: https://regex101.com/r/vC7mI1/1


    If my post was helpful to you, then express your gratitude using Rate this Post.
    And if your problem is SOLVED, then please Mark the Thread as RESOLVED (see it in action - video)
    My system: AMD FX 6100, Gigabyte Motherboard, 8 GB Crossair Vengance, Cooler Master 450W Thunder PSU, 1.4 TB HDD, 18.5" TFT(Wide), Antec V1 Cabinet

    Social Group: VBForums - Developers from India


    Skills: PHP, MySQL, jQuery, VB.Net, Photoshop, CodeIgniter, Bootstrap,...

  3. #3

    Thread Starter
    Fanatic Member
    Join Date
    Aug 2007
    Posts
    912

    Re: regex date time from string

    it works :-) thanks a lot

Posting Permissions

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



Click Here to Expand Forum to Full Width