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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T16:08:17+00:00 2026-05-15T16:08:17+00:00

So I was looking at how I could display a Desktop Notification using a

  • 0

So I was looking at how I could display a Desktop Notification using a Google Chrome extensions when I came across these lines of code:

var time = /(..)(:..)/(Date());              // The prettyprinted time.
var hour = time[1] % 12 || 12;               // The prettyprinted hour.
var period = time[1] < 12 ? 'a.m.' : 'p.m.'; // The period of the day.

What the heck does all of this do?

  • 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-15T16:08:17+00:00Added an answer on May 15, 2026 at 4:08 pm

    Fascinating, I’ve not seen this before:

    /regex/(...);
    

    EDIT: see this!

    This:

    /(..)(:..)/(Date());
    // seems to emulate the functionality of exec()
    

    Will return the match (array of matched groups) of the regular expression, /(..)(:..)/, against the string (Date()):

    "Thu Jul 08 2010 09:40:38 GMT+0200 (W. Europe Daylight Time)"
    

    (or whatever time it happens to be)

    The returned array (the match), in this case, is:

    ["09:40", "09", ":40"]
    

    This line:

    var hour = time[1] % 12 || 12; 
    

    …simply determines the hour. If the hour is falsey (i.e. 0) then it defaults to 12 — this makes it possible for the next statement to return the correct am/pm suffix. (12:00 is am).

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

Sidebar

Related Questions

I'm looking for something along these lines: <TextBlock Grid.Column=1 Text=Welcome, {Binding UserName}! /> This
I have been looking at nestedSet behaviour in symfony using doctrine, to display a
I'm looking at using fullCalendar and using qTip to display a description using eventMouseover.
I have been looking everywhere but could not find a tutorial for this. I
I am looking for ways that someone could maliciously pause a Flash movie -
I'm looking for a library that could be used to manipulate audio files. Essentially
I am looking for an algorithm that could find the two most distant elements
I'm looking for a queuing system that could support the following scenario: A client
I'm looking for a good address-parser that could parser any free texts and generate
I am currently looking into spliting a very long string that could contain HTML

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.