formatting date() and nbsp;

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • JS

    formatting date() and nbsp;

    What I have is a date that I'd like to format to keep it together on
    one line using non-breaking spaces.

    I started with:
    date ("l F&nbsp ;j, Y", $unixtime);

    and soon realized that the letters n and s are reserved characters for
    the date command, so I did this:

    $mydate =date ("l&\nb\sp;F&\n b\sp;j,&\nb\sp; Y", $unixtime);

    The &, b, and p don't need to be escaped since they aren't listed as
    being special characters for the date command. But no go. All it was
    insert a new line in the middle to replace the \n and a space for the
    \s. But as far as I can tell the space it inserts for the \s isn't
    and html non-breaking space.

    Then I tried:

    $mydate =date ("l"."  " . "F" . " ". "j," . " " . "Y",
    $unixtime);

    But the function does all of the string concatenation before it
    substitutes the characters for the time information, so that doesn't
    work either.

    I know I can go through and use:

    $mydate str_replace(" ", " ", $mydate);

    but I thought there might be a better way. Surely there's some way to
    tell date() that I want the character n, not the numeric
    representation of the month and not a new line character.

    Any ideas?

    Thanks
  • boclair

    #2
    Re: formatting date() and nbsp;


    "JS" <jd142@hotmail. com> wrote in message
    news:b072334c.0 308061701.2d306 7aa@posting.goo gle.com...[color=blue]
    > What I have is a date that I'd like to format to keep it together on
    > one line using non-breaking spaces.
    >
    > I started with:
    > date ("l&nbsp;F&nbsp ;j,&nbsp;Y", $unixtime);
    >[/color]
    This is not applicable?

    $mydate =date ("l F j, Y", $unixtime);

    <nobr>$mydate </nobr>

    Louise


    Comment

    • JS

      #3
      Re: formatting date() and nbsp;

      David Mackenzie <dcm@tarbrax.fr eeserve.co.uk> wrote:[color=blue]
      > From the manual ( http://uk2.php.net/date ):
      > <quote>
      > You can prevent a recognized character in the format string from being
      > expanded by escaping it with a preceding backslash. If the character
      > with a backslash is already a special sequence, you may need to also
      > escape the backslash.
      > </quote>
      >
      > So
      > $mydate =date ("l&\\nb\\sp;F& \\nb\\sp;j,&\\n b\\sp;Y", $unixtime);
      >
      > should do it (untested!)[/color]

      Thanks. I read the manual page three times and just kept missing it.
      Damn these eyes. Too late. ;)

      Thanks

      Comment

      • Andy Hassall

        #4
        Re: formatting date() and nbsp;

        On Thu, 07 Aug 2003 10:07:09 GMT, "boclair" <boclair@bigpon d.net.au> wrote:
        [color=blue]
        >This is not applicable?
        >
        ><nobr>$mydat e</nobr>[/color]

        <nobr> is not an HTML element.



        --
        Andy Hassall (andy@andyh.co. uk) icq(5747695) (http://www.andyh.co.uk)
        Space: disk usage analysis tool (http://www.andyhsoftware.co.uk/space)

        Comment

        • matty

          #5
          Re: formatting date() and nbsp;

          Andy Hassall wrote:
          [color=blue]
          > On Thu, 07 Aug 2003 10:07:09 GMT, "boclair" <boclair@bigpon d.net.au>
          > wrote:
          >[color=green]
          >>This is not applicable?
          >>
          >><nobr>$mydate </nobr>[/color]
          >
          > <nobr> is not an HTML element.
          >
          > http://www.w3.org/TR/html4/index/elements.html[/color]

          If you want &nbsp; instead of space, the other solution
          is to use str_replace on your formatted string

          Comment

          Working...