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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T19:54:51+00:00 2026-05-22T19:54:51+00:00

I echo this : php> echo date(Y-m-d\TH:i:s); 2011-05-27T11:21:23 How can do with date function

  • 0

I echo this :

  php> echo date("Y-m-d\TH:i:s");
      2011-05-27T11:21:23

How can do with date function to get this date format:

2011-01-12T14:41:35.7042252+01:00 (for example)

35.7042252 => seconds.decimal-fraction-of-second

I have tried:

php> function getTimestamp()
 ... {
 ...         return date("Y-m-d\TH:i:s") . substr((string)microtime(), 1, 8);
 ... }

php> echo getTimestamp();
2011-05-27T15:34:35.6688370 // missing +01:00 how can I 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-22T19:54:52+00:00Added an answer on May 22, 2026 at 7:54 pm
    date('Y-m-d\TH:i:s.uP')
    

    u for microseconds was added in PHP 5.2.2. For earlier or (still) broken versions (see comments):

    date('Y-m-d\TH:i:s') . substr(microtime(), 1, 8) . date('P')
    

    Or, to avoid two calls to date:

    date(sprintf('Y-m-d\TH:i:s%sP', substr(microtime(), 1, 8)))
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This example is from php.net: <?php function Test() { static $a = 0; echo
<?php date_default_timezone_set(Spain/Madrid); $date=date(H:i:s); echo $date; ?> how can i set the date to my
I can't seem to find the problem with this php function i wrote that
I want to do something like this: <?php echo date('Y'); ?> But then in
this show the next Saturday <?php echo date(l,j M Y, strtotime(next saturday)); ?> i.e
I have this PHP code echo '<a href=# onclick=updateByQuery(\'Layer3\', ' . json_encode($query) . ');>Link
For some reason This php script won't echo anything: <?php setcookie(pop,'hi',time()+604800); echo $HTTP_COOKIE_VARS['pop']; ?>
I have this simple php script <?php echo '<pre>'; // Outputs all the result
Often when writing PHP I'll have it output some HTML like this - echo
this is my entire PHP code: <?php if(empty($_POST['selid'])) {echo no value selected; } else

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.