Jump to content
Welcome, Guest
Existing user? Sign In

Sign In



Sign Up
The MatriX
  • Welcome To Ghbsys
  • CS GO Streaming Version is released. Have fun streaming while cheating!
  • Have a Payment Issue? Send us a Support ticket.
  • Make a thread if you need support or join our discord for live support.
  • Have Suggestions? Make a thread and you'll earn Ghbsys Points for implemented suggestions.
  • Join our discord to stay well connected! Don't forget to integrate your discord to the site
  • Welcome to [GHB] - GAmEhAcKbAsTaRdS Forum

    Welcome to [GHB] - GAmEhAcKbAsTaRdS Forum, like most online communities you must register to view or post in our community, but don't worry this is a simple free process that requires minimal information for you to signup. Be apart of [GHB] - GAmEhAcKbAsTaRdS Forum by signing in or creating an account.
    • Start new topics and reply to others
    • Subscribe to topics and forums to get email updates
    • Get your own profile page and make new friends
    • Send personal messages to other members.

    PHP Zeit Formate


    ~Beefy~
     Share

    Recommended Posts

    Hallöle.

    Ich mach einfach mal nach lust und laune n Thema.

    Also.

    Wollt ihr ein Datum per String haben und dann umwandeln?

    Alles ohne RegEx? Einfach!

    Als beispiel nehme ich das Timestamp einer einfachen MySQL Tabelle.

    $timestamp1 = "2011-23-04 14:15:30";

     

    So. Das wäre ein Timestamp in der MySQL Tabelle (CURRENT_TIMESTAMP).

    Um das in das Format Date zu wandeln machen wir:

     

    $date1 = strtotime("Y-m-d H:i:s", $timestamp1); //Ich hoffe, ich habe das richtige Format erwischt und nicht versehentlich was groß/klein gemacht.

    Nun. Bei strtotime wird ein Timestamp direkt mit umgewandelt.

    Für CURRENT_TIMESTAMP sähe das Format wie oben aus (in etwa :D).

     

    So. Dann gibts aber noch mktime und so.

    mktime = make time

    Ein beispiel:

     

    $time1 = mktime(2011, 23, 04, 14, 15, 30); //Wäre selbes datum wie $timestamp1, nur direkt schon als date format.

    und was machen wir damit? :)

    $time2 = "Jahr:".date("Y", $time1);

    $time3 = "Monat:".date("m", $time1);

    $time3 = "Tag:".date("d", $time1);

     

    Da haben wir jetzt Jahr, Monat und Tag formatiert.

    Für weitere formatierungen empfehle ich euch....:

    Zeit Formatierungen

     

    Desweiteren frage ich mich: Wieso ein Tutorial? Es gibt genug :o

    Fragt ihr euch jetzt bestimmt auch.

    Naja, es ist mein Werk und ich bereichere damit die Welt und alle anderen die sich damit beschäftigen.

    Ich hab das Thema nur aus langeweile gemacht. Bye!

    Link to comment
    Share on other sites

    Guest
    This topic is now closed to further replies.
     Share

    • Recently Browsing   0 members

      • No registered users viewing this page.
    ×
    ×
    • Create New...