quick php date() help

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • BradM
    Confirmed User
    • Dec 2003
    • 3397

    #1

    quick php date() help

    You'll see what I am trying to go... hopefully lol


    $yesterday = date(("F")+(("d")-1)+("Y"));

    I am trying to minus 1 from the d, so I get "yesterday". How can I do this? I am probably making it too difficult. :p
  • Arty
    Confirmed User
    • Nov 2002
    • 880

    #2
    Originally posted by BradM
    You'll see what I am trying to go... hopefully lol


    $yesterday = date(("F")+(("d")-1)+("Y"));

    I am trying to minus 1 from the d, so I get "yesterday". How can I do this? I am probably making it too difficult. :p
    $yesterday = date("F d Y",mktime(0,0,0,date("F"),date("d")-1,date("Y")));

    Comment

    • Fukeneh
      Confirmed User
      • Mar 2004
      • 1245

      #3
      isnt there already a flag for yesterday in php?

      Comment

      • patch
        Registered User
        • Jul 2002
        • 19

        #4
        $yesterday = date("F d Y", time()-86400);


        Tired of spammers? Click here... Works for me!

        Comment

        • BradM
          Confirmed User
          • Dec 2003
          • 3397

          #5
          Originally posted by Arty
          $yesterday = date("F d Y",mktime(0,0,0,date("F"),date("d")-1,date("Y")));
          I tried that dude, the output I get is: December 27 2003

          REALLY weird hey?

          Comment

          • BradM
            Confirmed User
            • Dec 2003
            • 3397

            #6
            Originally posted by patch
            $yesterday = date("F d Y", time()-86400);
            Cheers patch, much appreciated!

            Comment

            • Arty
              Confirmed User
              • Nov 2002
              • 880

              #7
              Sorry Correction,

              $yesterday = date("F d Y",mktime(0,0,0,date("m"),date("d")-1,date("Y")));

              Comment

              • fuzebox
                making it rain
                • Oct 2003
                • 22355

                #8
                This thread is hilarious

                Cheers to patch for an answer that makes sense.

                Comment

                • BradM
                  Confirmed User
                  • Dec 2003
                  • 3397

                  #9
                  Originally posted by fuzebox
                  This thread is hilarious

                  Cheers to patch for an answer that makes sense.
                  Fuzebox is a c-unt

                  Comment

                  • Intrigue
                    Confirmed User
                    • Feb 2004
                    • 662

                    #10
                    hey dude, just use strtotime("-1 day");

                    Comment

                    • patch
                      Registered User
                      • Jul 2002
                      • 19

                      #11
                      Originally posted by Intrigue
                      hey dude, just use strtotime("-1 day");
                      My eyes prefer "-86400" to "- 1 day"

                      And the full line is shorter that way....


                      Tired of spammers? Click here... Works for me!

                      Comment

                      • JSA Matt
                        So Fucking Banned
                        • Aug 2003
                        • 5464

                        #12
                        date("F d Y", strtotime("yesterday"));
                        date("F d Y", strtotime("-1 day"));

                        should have plenty of ways to do it lol.. I prefer the mktime method

                        Comment

                        • KC
                          Confirmed User
                          • Jan 1995
                          • 2417

                          #13
                          You guys are crazy.

                          Yesterday was the 28th.

                          Jupiter Hosting, Inc.
                          Vice President, Business Development
                          kc (AT) jupiterhosting.com

                          Comment

                          • Arty
                            Confirmed User
                            • Nov 2002
                            • 880

                            #14
                            Originally posted by patch
                            My eyes prefer "-86400" to "- 1 day"

                            And the full line is shorter that way....
                            It's not only shorter but also faster than other solutions, especially than the strtotime solution

                            Comment

                            Working...