Timestamp help

Forum
Last Post
Threads / Messages

Ittermat

The awesomesauce
Member
Joined
Feb 2, 2016
Messages
304
Points
18
Location
in front of my laptop
Mysidian Dollar
21,294
I need some help with formatting Timestamps.

I have a last login thing- but I want it to show a date- Like dd-mm-YYYY
but I cant get the timestamp converted...

And Im not sure what to put in/how to do that.

loginpic1.png
 
ITs this area of it... the bio information

PHP:
                <b>Status:</b> {$online}</br>

                <b>Title:</b> {$user->usergroup}<br>

                <b>Member Since:</b> {$current_user_i2->membersince} </br>
 
                <b>Last Login:{$current_user_i2->lastlogin}<br>

                <b>Gender:</b> {$current_user->gender}</br>

                <b>Favorite color:</b> {$current_user->color}</br>

                <b>Nickname:</b> {$current_user->nickname}</br>

                <b>About:</b> {$current_user->bio}</br>

Or do you need the whole thing?
 
I had to do it this way cuz its super long and it wouldnt let me send it as an RTF file
 

Attachments

  • profileviewforfamer.zip
    4.9 KB · Views: 2
I dont mean the entire file, just the section/method of the code where its defined. Also can you use pastebin? The code is very poorly formatted in the word document and I have a hard time reading it.
 
I've never used pastebin... but yea Its a long file and theres a HUGE area for the Public function... anyway I'll do that when I get home later.
 
Okay then, though I think you can attach a .php file? I dont understand why using .rtf format, its not used for code and the formatting makes it very difficult for me to read.
 
Well find this block of code(around line 176)
PHP:
        else{$halloween = "";}



        $document->add(new Comment("

        {$halloween}

        <div style='border-radius: 25px; border: 5px solid #7f7f7f; padding: 10px; overflow:auto;'>

        <div style='border-radius: 25px; border: 5px solid #7f7f7f; padding: 10px; float:right;'>{$group_image}</div>

        <div style='border-radius: 25px; border: 5px solid #7f7f7f; padding: 10px; float:right;'>{$favpet_image}</div>

            <img src='{$current_user->avatar}' class='float-left' style='height:150px; width:100px;'>

            <p>
              

                <b>Status:</b> {$online}</br>

                <b>Title:</b> {$user->usergroup}<br>

                <b>Member Since:</b> {$current_user_i2->membersince} </br>
   
                <b>Last Login:$lastLoginDate->format(“Y-m-d”)(“@{$current_user_i2->lastlogin}”);<br>

                <b>Gender:</b> {$current_user->gender}</br>

                <b>Favorite color:</b> {$current_user->color}</br>

                <b>Nickname:</b> {$current_user->nickname}</br>

                <b>About:</b> {$current_user->bio}</br>


            </p>

            <p>

            <b> |  | <b><a href='/messages/newpm/{$mysidia->input->get('user')}'>  Message</a> |  | <a href='/trade/offer/user/{$current_user_i2->uid}'> Trade</a><b>  |  | <a href='/friends/request/{$current_user_i2->uid}'>  Become friend!</a> |  | <a href=' https://atrocity.mysidiahost.com/mybb/member.php?action=profile&uid={$current_user->uid}'><b>  Forum profile </a> |  | <a href='https://atrocity.mysidiahost.com/profile/diary/{$current_user->username}'><b>   Read My Diary!</br> </a> |  | <a href='https://atrocity.mysidiahost.com/profile/diary/{$current_user->username}'><b>  Challenge me! </a>*Coming soon!*
            </p>

            <hr style='height:5px; background-color: #7f7f7f;'>",false));

Replace by:

PHP:
        else{$halloween = "";}


        $lastLoginDate = $current_user_i2->lastlogin ? new DateTime("@{$current_user_i2->lastlogin}")->format("d-m-Y") : "N/A";

        $document->add(new Comment("

        {$halloween}

        <div style='border-radius: 25px; border: 5px solid #7f7f7f; padding: 10px; overflow:auto;'>

        <div style='border-radius: 25px; border: 5px solid #7f7f7f; padding: 10px; float:right;'>{$group_image}</div>

        <div style='border-radius: 25px; border: 5px solid #7f7f7f; padding: 10px; float:right;'>{$favpet_image}</div>

            <img src='{$current_user->avatar}' class='float-left' style='height:150px; width:100px;'>

            <p>
              

                <b>Status:</b> {$online}</br>

                <b>Title:</b> {$user->usergroup}<br>

                <b>Member Since:</b> {$current_user_i2->membersince} </br>
   
                <b>Last Login: {$lastLoginDate}<br>

                <b>Gender:</b> {$current_user->gender}</br>

                <b>Favorite color:</b> {$current_user->color}</br>

                <b>Nickname:</b> {$current_user->nickname}</br>

                <b>About:</b> {$current_user->bio}</br>


            </p>

            <p>

            <b> |  | <b><a href='/messages/newpm/{$mysidia->input->get('user')}'>  Message</a> |  | <a href='/trade/offer/user/{$current_user_i2->uid}'> Trade</a><b>  |  | <a href='/friends/request/{$current_user_i2->uid}'>  Become friend!</a> |  | <a href=' https://atrocity.mysidiahost.com/mybb/member.php?action=profile&uid={$current_user->uid}'><b>  Forum profile </a> |  | <a href='https://atrocity.mysidiahost.com/profile/diary/{$current_user->username}'><b>   Read My Diary!</br> </a> |  | <a href='https://atrocity.mysidiahost.com/profile/diary/{$current_user->username}'><b>  Challenge me! </a>*Coming soon!*
            </p>

            <hr style='height:5px; background-color: #7f7f7f;'>",false));

Anyway in future you dont have to show the entire script file, just show the public function view() is good enough.
 
when I put in this



$lastLoginDate = $current_user_i2->lastlogin ? new DateTime("@{$current_user_i2->lastlogin}")->format("d-m-Y") : "N/A";


It gives me "syntax error, Unexpected T_Object_operator error
 
Oh I forgot that PHP does not behave like Java for calling methods on anonymous object.

This should do:
PHP:
$lastLoginDate = $current_user_i2->lastlogin ? (new DateTime("@{$current_user_i2->lastlogin}"))->format("d-m-Y") : "N/A";
 
no no I mean- how do I change it else where? Like in the code-

<b>Member Since:</b> {$current_user_i2->membersince}</br>

What do I add to this to change the date format? Since its not a jumble of numbers
 
Well behind the last login date variable declaration:
PHP:
       $lastLoginDate = $current_user_i2->lastlogin ? (new DateTime("@{$current_user_i2->lastlogin}"))->format("d-m-Y") : "N/A";

add a new line:
PHP:
     $memberSince = new DateTime($current_user_i2->membersince);

Then replace this:

PHP:
<b>Member Since:</b> {$current_user_i2->membersince}</br>

By:

PHP:
<b>Member Since:</b> {$membersince->format('d-m-Y')}</br>
 
@Hall of Famer Do you know why my lastLoginDate would be showing the N/A from this:

$lastLoginDate = $current_user_i2->lastlogin ? (new DateTime("@{$current_user_i2->lastlogin}"))->format("d-m-Y") : "N/A";

? I tried doing this since it was working for Ittermat, but it won't work the same for me. It just does the N/A and won't stamp a date. My database shows the same as hers.
 
Maybe the user has logged in, but the data aint saved properly. Or perhaps the login data was saved but not retrieved properly. You need to check the database table where the lastlogin field is stored, and see if it is 0 or NULL.
 

Similar threads

Users who are viewing this thread

  • Forum Contains New Posts
  • Forum Contains No New Posts

Forum statistics

Threads
4,277
Messages
33,118
Members
1,602
Latest member
BerrieMilk
BETA

Latest Threads

Top